https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71336
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|rtl-optimization |tree-optimization --- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #3) > I guess it could be useful even without lea. Pretty much. Even on aarch64 we get for the original case: ubfiz w0, w0, 2, 1 add w0, w0, 3 ret vs tst x0, 1 mov w2, 7 mov w1, 3 csel w0, w2, w1, ne ret For something slightly different: unsigned test(unsigned a) { return a & 4 ? 7 : 3; } unsigned test1(unsigned a) { a &= 4; a >>= 2; return a*4 + 3; } ---- We get: tst x0, 4 mov w2, 7 mov w1, 3 csel w0, w2, w1, ne ret vs and w0, w0, 4 add w0, w0, 3 ret