------- Comment #2 from mikpe at it dot uu dot se 2010-05-30 14:50 -------
I can confirm this wrong-code when gcc 4.4/4.5 targets arm-unknown-eabi.
However, a 4.4/4.5 running natively on arm-unknown-linux-gnueabi does not
exhibit this behaviour. There there's no 'comparison always true' warning, and
the generated code contains conditional instructions where the arm-unknown-eabi
gcc emitted unconditional instructions.
This is what 4.5-20100527 generates for me on arm-unknown-linux-gnueabi:
sub r1, r1, #1
cmp r1, #2
ldrls r3, .L4
movhi r1, #1
ldrls r1, [r3, r1, asl #2]
b open
.L5:
.align 2
.L4:
.word .LANCHOR0
.size _Z9open_filePKc8OpenMode, .-_Z9open_filePKc8OpenMode
.section .rodata
.align 2
.LANCHOR0 = . + 0
.type CSWTCH.2, %object
.size CSWTCH.2, 12
CSWTCH.2:
.word 74
.word 3
.word 75
My guess is that the subtract+compare is done in a too narrow mode, resulting
in the warning and subsequent omission of the conditionals.
Also, it's not a jump table but a lookup table.
--
mikpe at it dot uu dot se changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikpe at it dot uu dot se
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44328