[Bug tree-optimization/71336] Suboptimal code generated for "(a & 1) ? (CST1 + CST2) : CST1"
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jul 20 00:19:53 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71336
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #6)
> Sorry this one is more correct
> Something like (very much pesdu code):
> (simplify
> (cond (eq (bit_and@0 @1 int_pow2p@2) integer_zerop) INTEGET_CST@3
> INTEGER_CST@4)
> (switch
> (if (@3 u> @4 && exact_pow2(@3 - @4))
> (convert (plus (mult (rshift @0:typeu @2) (minus @3:typeu @4:typeu))
> @4:typeu)))
> (if (@4 u> @3 && exact_pow2(@4 - @3))
> (convert (minus (mult (rshift @0:typeu @2) (minus @4:typeu @3:typeu))
> @3:typeu))
> ))
>
> The mult could be changed to lshift to be more correct.
I should note, the above is now only possible because of the recent changes I
did to phi-opt. You no longer need to open code anything in phi-opt for things
like this bug, just add them to match.pd and be done with it :).
More information about the Gcc-bugs
mailing list