1 /*===-- umodsi3.S - 32-bit unsigned integer modulus -----------------------===//
3 * The LLVM Compiler Infrastructure
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
8 *===----------------------------------------------------------------------===//
10 * This file implements the __umodsi3 (32-bit unsigned integer modulus)
11 * function for the ARM architecture. A naive digit-by-digit computation is
12 * employed for simplicity.
14 *===----------------------------------------------------------------------===*/
16 #include "../assembly.h"
25 DEFINE_COMPILERRT_FUNCTION(__umodsi3)
26 // We use a simple digit by digit algorithm; before we get into the actual
27 // divide loop, we must calculate the left-shift amount necessary to align
28 // the MSB of the divisor with that of the dividend.
30 tst b, b // detect b == 0
32 bxeq lr // return a if b == 0
34 bxlt lr // return a if MSB(a) < MSB(b)
36 LOCAL_LABEL(mainLoop):
37 // This loop basically implements the following:
46 // Note that this does not perform the final iteration (i == 0); by doing it
47 // this way, we can merge the two branches which is a substantial win for
48 // such a tight loop on current ARM architectures.
52 bhi LOCAL_LABEL(mainLoop)
54 // Do the final test subtraction and update of remainder (i == 0), as it is
55 // not performed in the main loop.