Compile following function with options -Os -mthumb -march=armv5te: int returnbool(int a, int b) { if (a < b) return 1; return 0; }
Gcc 4.5 generates: lsr r3, r1, #31 asr r2, r0, #31 cmp r0, r1 adc r2, r2, r3 mov r0, r2 mov r3, #1 eor r0, r0, r3 @ sp needed for prologue bx lr while gcc 4.3.1 generates: push {lr} mov r3, #1 cmp r0, r1 blt .L2 mov r3, #0 .L2: mov r0, r3 @ sp needed for prologue pop {pc} If we count instructions to do comparison only, they are 7 vs 4. I don't know if it is faster to replace one branch instruction with 4 alu instructions. It is definitely a regression for code size. The long code sequence is generated by expand pass. -- Summary: code size explosion for integer comparison Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: carrot at google dot com GCC build triplet: i686-linux GCC host triplet: i686-linux GCC target triplet: arm-eabi http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40741