[Bug tree-optimization/55157] Missed VRP with != 0 and multiply
aldyh at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Nov 4 19:45:06 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55157
--- Comment #9 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Aldy Hernandez from comment #7)
> (In reply to Andrew Macleod from comment #6)
> > (In reply to Aldy Hernandez from comment #4)
> > 3) It also seems to me that you then only need to add the zero/union iff the
> > trailing bit has zeros. ie, if the are no trailing zeros, then just set the
> > lb to 0, and calculate the UB based on the clz.
>
> That actually made it slightly worse.
I did some more testing. Your suggestions actually improved the original code
from 3.3% to 2.5%, but I added:
+ if (!wi::neg_p (mask, TYPE_SIGN (type ())) && prec > 1)
instead of:
+ if (TYPE_UNSIGNED (type ()) && prec > 1)
because we can still perform the optimization for signed positive numbers. And
that brought the slowdown back to 3.6%. But ISTM that we're gonna do it, might
as well do it for signed numbers as well.
Hmmmm... I think we really should do our best to represent masks as ranges as
it makes other optimizations possible across the ranger ecosystem. But I'm not
ecstatic about the 3.6% drop (even though overall compilation is unaffected).
More information about the Gcc-bugs
mailing list