unsigned parity(unsigned x) { x ^= x >> 16; x ^= x >> 8; x ^= x >> 4; x &= 0xf; return (0x6996 >> x) & 1; }
gcc 4.2.0 20060506 produces: extwl a0,0x2,t2 lda v0,27030 xor t2,a0,t2 zapnot t2,0xf,t1 # redundant zero-extension srl t1,0x8,t1 xor t1,t2,t1 zapnot t1,0xf,t0 # redundant zero-extension srl t0,0x4,t0 xor t0,t1,t0 and t0,0xf,t0 sra v0,t0,v0 and v0,0x1,v0 -fsee doesn't change anything here. -- Summary: zero extension not eliminated Product: gcc Version: 4.2.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: falk at debian dot org GCC build triplet: alphaev68-unknown-linux-gnu GCC host triplet: alphaev68-unknown-linux-gnu GCC target triplet: alphaev68-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27469