[Bug tree-optimization/14495] [tree-ssa] Propagate range info into a switch statement
wouter dot vermaelen at pi dot be
gcc-bugzilla@gcc.gnu.org
Thu Apr 20 10:58:00 GMT 2006
------- Comment #5 from wouter dot vermaelen at pi dot be 2006-04-20 10:58 -------
I think something similar happens for the following code.
int f(int a) {
switch (a & 7) {
case 0: return 2;
case 1: return 3;
case 2: return 5;
case 3: return 7;
case 4: return 11;
case 5: return 13;
case 6: return 17;
case 7: return 19;
}
}
Part of the generated code looks like this:
movl 8(%ebp), %eax
andl $7, %eax
cmpl $7, %eax
jbe .L15
popl %ebp
ret
.p2align 4,,15
.L15:
jmp *.L11(,%eax,4)
The test for values bigger than 7 is clearly not needed here.
I don't know much about compiler technologie, but maybe this specific case is
easier to solve with some peephole optimization?
I have seen real code (Z80 emulator or HQ2x scaler algorithm) that does a
switch on a unsigned char and handles all 256 cases. Code like that would
benefit from this optimization.
Thanks.
--
wouter dot vermaelen at pi dot be changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wouter dot vermaelen at pi
| |dot be
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14495
More information about the Gcc-bugs
mailing list