2019-02-24 06:06:06 |
Dan Lewis |
bug |
|
|
added bug |
2019-02-24 06:08:50 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
|
2019-02-24 06:10:54 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
|
2019-02-24 06:12:38 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
|
2019-02-24 06:12:57 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
|
2019-02-24 06:13:10 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8:
AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
|
2019-02-24 06:13:37 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8:
AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8:
ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4:
subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8:
AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
|
2019-02-24 06:13:59 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8:
ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4:
subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8:
AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8:
ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4:
subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8:
AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
|
2019-02-24 06:14:39 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8:
ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4:
subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8:
AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
<code>
Rem8:
ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4:
subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
</code>
However, there's a much simpler and faster solution:
Rem8:
AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
|
2019-02-24 06:14:54 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
<code>
Rem8:
ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4:
subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
</code>
However, there's a much simpler and faster solution:
Rem8:
AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
<pre>
Rem8:
ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4:
subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
</pre>
However, there's a much simpler and faster solution:
Rem8:
AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
|
2019-02-24 06:15:08 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
<pre>
Rem8:
ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4:
subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
</pre>
However, there's a much simpler and faster solution:
Rem8:
AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8:
ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4:
subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8:
AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
|
2019-02-24 06:21:28 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8:
ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4:
subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8:
AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
|
2019-02-24 06:41:46 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n MOD 8
TST R1,R0,ASR 31 // Is n < 0 && (n MOD 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n MOD 8) - 8
MOVEQ R0,R1 // No: Return (n MOD 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n & 8
TST R1,R0,ASR 31 // Is n < 0 && (n & 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n & 8) - 8
MOVEQ R0,R1 // No: Return (n & 8)
BX LR |
|
2019-02-24 06:50:12 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n & 8
TST R1,R0,ASR 31 // Is n < 0 && (n & 8) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n & 8) - 8
MOVEQ R0,R1 // No: Return (n & 8)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n & 7
TST R1,R0,ASR 31 // Is n < 0 && (n & 7) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n & 7) - 8
MOVEQ R0,R1 // No: Return (n & 7)
BX LR |
|
2019-02-24 17:30:18 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: AND R1,R0,7 // R1 = n & 7
TST R1,R0,ASR 31 // Is n < 0 && (n & 7) != 0 ?
ITE NE
SUBNE R0,R1,8 // Yes: Return (n & 7) - 8
MOVEQ R0,R1 // No: Return (n & 7)
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: LSR R1,R0,31
ANDS R0,R0,7
IT NE
SUBNE R0,R0,R1,LSL 3
BX LR |
|
2019-02-24 17:55:11 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: LSR R1,R0,31
ANDS R0,R0,7
IT NE
SUBNE R0,R0,R1,LSL 3
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: LSRS R1,R0,31
ANDS R0,R0,7
IT NE
SUBNE R0,R0,R1,LSL 3
BX LR |
|
2019-02-24 17:55:37 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: LSRS R1,R0,31
ANDS R0,R0,7
IT NE
SUBNE R0,R0,R1,LSL 3
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: LSRS R1,R0,31
ANDS R0,R0,7
IT NE
SUBNE R0,R0,R1,LSL 3
BX LR |
|
2019-02-25 15:31:25 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution:
Rem8: LSRS R1,R0,31
ANDS R0,R0,7
IT NE
SUBNE R0,R0,R1,LSL 3
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution (see below). Computing the remainder for other powers of 2 is simply a matter of changing the constant 7 to 2^k-1 and the constant 3 to k.
Rem8: LSRS R1,R0,31
ANDS R0,R0,7
IT NE
SUBNE R0,R0,R1,LSL 3
BX LR |
|
2019-03-02 19:19:43 |
Dan Lewis |
description |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 5.4 with -O3 into:
Rem8: ldr r3, .L5
ands r3, r3, r0
cmp r3, #0
blt .L4
mov r0, r3
bx lr
.L4: subs r3, r3, #1
orn r3, r3, #7
adds r3, r3, #1
mov r0, r3
bx lr
.L5: .word -2147483641 // Same as 0x80000007
However, there's a much simpler and faster solution (see below). Computing the remainder for other powers of 2 is simply a matter of changing the constant 7 to 2^k-1 and the constant 3 to k.
Rem8: LSRS R1,R0,31
ANDS R0,R0,7
IT NE
SUBNE R0,R0,R1,LSL 3
BX LR |
The following C code:
int Rem8(int n)
{
return n % 8 ;
}
is recognized as a special case (divisor is power of 2) and compiled by gcc version 8.2 with -O3 into:
Rem8: rsbs r3, r0, #0
and r3, r3, #7
and r0, r0, #7
it pl
rsbpl r0, r3, #0
bx lr
However, I believe there's a simpler and faster solution (see below). Computing the remainder for other powers of 2 is simply a matter of changing the constant 7 to 2^k-1 and the constant 3 to k.
Rem8: LSRS R1,R0,31
ANDS R0,R0,7
IT NE
SUBNE R0,R0,R1,LSL 3
BX LR |
|