Track GCC PR http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43721
Once this bug is fixed, code size of CINT2000/252.eon/src/myrand.cc:myrand() can be reduced to some extent.
GCC FSF turnk (20100802) generates code like this, 0000000c <_Z7my_randv>: c: b570 push {r4, r5, r6, lr} e: 4c0d ldr r4, [pc, #52] ; (44 <_Z7my_randv+0x38>) 10: 490d ldr r1, [pc, #52] ; (48 <_Z7my_randv+0x3c>) 12: 6825 ldr r5, [r4, #0] 14: 4e0d ldr r6, [pc, #52] ; (4c <_Z7my_randv+0x40>) 16: 4628 mov r0, r5 18: f7ff fffe bl 0 <__aeabi_idiv> 1c: 4346 muls r6, r0 1e: 490a ldr r1, [pc, #40] ; (48 <_Z7my_randv+0x3c>) 20: 4628 mov r0, r5 22: f7ff fffe bl 0 <__aeabi_idivmod> 26: f244 13a7 movw r3, #16807 ; 0x41a7 2a: fb03 6601 mla r6, r3, r1, r6 2e: 2e00 cmp r6, #0 30: bfdc itt le 32: f106 4600 addle.w r6, r6, #2147483648 ; 0x80000000 36: 3e01 suble r6, #1 38: 6026 str r6, [r4, #0] 3a: 6820 ldr r0, [r4, #0] 3c: f3c0 200e ubfx r0, r0, #8, #15 40: bd70 pop {r4, r5, r6, pc} 42: bf00 nop
Once bug is fixed, code can be better, 00000006 <_Z7my_randv>: 6: b510 push {r4, lr} 8: 4c0a ldr r4, [pc, #40] ; (34 <_Z7my_randv+0x2e>) a: 490b ldr r1, [pc, #44] ; (38 <_Z7my_randv+0x32>) c: 6820 ldr r0, [r4, #0] e: f7ff fffe bl 0 <__aeabi_idivmod> 12: f244 12a7 movw r2, #16807 ; 0x41a7 16: 4351 muls r1, r2 18: f46f 7231 mvn.w r2, #708 ; 0x2c4 1c: 4350 muls r0, r2 1e: eb01 0080 add.w r0, r1, r0, lsl #2 22: 2800 cmp r0, #0 24: dc02 bgt.n 2c <_Z7my_randv+0x26> 26: f06f 4100 mvn.w r1, #2147483648 ; 0x80000000 2a: 4408 add r0, r1 2c: 6020 str r0, [r4, #0] 2e: f3c0 200e ubfx r0, r0, #8, #15 32: bd10 pop {r4, pc}
Track GCC PR http:// gcc.gnu. org/bugzilla/ show_bug. cgi?id= 43721
Once this bug is fixed, code size of CINT2000/ 252.eon/ src/myrand. cc:myrand( ) can be reduced to some extent.
GCC FSF turnk (20100802) generates code like this,
0000000c <_Z7my_randv>:
c: b570 push {r4, r5, r6, lr}
e: 4c0d ldr r4, [pc, #52] ; (44 <_Z7my_randv+0x38>)
10: 490d ldr r1, [pc, #52] ; (48 <_Z7my_randv+0x3c>)
12: 6825 ldr r5, [r4, #0]
14: 4e0d ldr r6, [pc, #52] ; (4c <_Z7my_randv+0x40>)
16: 4628 mov r0, r5
18: f7ff fffe bl 0 <__aeabi_idiv>
1c: 4346 muls r6, r0
1e: 490a ldr r1, [pc, #40] ; (48 <_Z7my_randv+0x3c>)
20: 4628 mov r0, r5
22: f7ff fffe bl 0 <__aeabi_idivmod>
26: f244 13a7 movw r3, #16807 ; 0x41a7
2a: fb03 6601 mla r6, r3, r1, r6
2e: 2e00 cmp r6, #0
30: bfdc itt le
32: f106 4600 addle.w r6, r6, #2147483648 ; 0x80000000
36: 3e01 suble r6, #1
38: 6026 str r6, [r4, #0]
3a: 6820 ldr r0, [r4, #0]
3c: f3c0 200e ubfx r0, r0, #8, #15
40: bd70 pop {r4, r5, r6, pc}
42: bf00 nop
Once bug is fixed, code can be better,
00000006 <_Z7my_randv>:
6: b510 push {r4, lr}
8: 4c0a ldr r4, [pc, #40] ; (34 <_Z7my_randv+0x2e>)
a: 490b ldr r1, [pc, #44] ; (38 <_Z7my_randv+0x32>)
c: 6820 ldr r0, [r4, #0]
e: f7ff fffe bl 0 <__aeabi_idivmod>
12: f244 12a7 movw r2, #16807 ; 0x41a7
16: 4351 muls r1, r2
18: f46f 7231 mvn.w r2, #708 ; 0x2c4
1c: 4350 muls r0, r2
1e: eb01 0080 add.w r0, r1, r0, lsl #2
22: 2800 cmp r0, #0
24: dc02 bgt.n 2c <_Z7my_randv+0x26>
26: f06f 4100 mvn.w r1, #2147483648 ; 0x80000000
2a: 4408 add r0, r1
2c: 6020 str r0, [r4, #0]
2e: f3c0 200e ubfx r0, r0, #8, #15
32: bd10 pop {r4, pc}