https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20517
Roger Sayle <roger at nextmovesoftware dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |roger at nextmovesoftware dot com Resolution|--- |FIXED Target Milestone|--- |4.6.4 --- Comment #8 from Roger Sayle <roger at nextmovesoftware dot com> --- GCC generates code without shifts for all the examples in comment #4, since around version 4.6.4. The "((x&0xf0)>>4) == 1" of the original, is now canonicalized to "((x>>4)&0xf) == 1" at the tree-level (to minimize the size of immediate constants). Whether ((x>>C1)&C2)==C3 is more/less efficient than (x&C4)==C5, where C4=C2<<C1 and C5=C3<<C1, depends upon the target, so this decision is made in the RTL optimizers, as explained in the PR's comments.