https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66552
--- Comment #9 from Li Jia He <helijia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #8) > (In reply to Andrew Pinski from comment #7) > > (In reply to Andrew Pinski from comment #6) > > > (In reply to Li Jia He from comment #5) > > > > Could we consider doing this optimization on gimple? I use the following > > > > code on gimple to produce optimized results on powerpc64. > > > > > > It might make sense. But fold-const.c might not be the correct location; > > > match.pd might be a better place for it. > > > > Something like: > > (simplify > > (rshift @0 (mod @1 integer_pow2p@2)) > > (rshift @0 (bit_and @1 (minus @1 { build_int_cst (TREE_TYPE (@1), 1); })))) > > Some typos: > (simplify > (rshift @0 (mod @1 integer_pow2p@2)) > (rshift @0 (bit_and @1 (minus @2 { build_int_cst (TREE_TYPE (@2), 1); })))) > > This would be under the for: > (for mod (ceil_mod floor_mod round_mod trunc_mod) Thank you for your suggestions. Let's try it on gcc11 stage1 ^ _ ^.