[PATCH v2] simplify-rtx: Simplify (op (and/ior x C1) C2) in special cases

Andrew Pinski andrew.pinski@oss.qualcomm.com
Fri Apr 10 02:10:49 GMT 2026


On Tue, Apr 7, 2026 at 9:44 PM Bohan Lei <garthlei@linux.alibaba.com> wrote:
>
> > If you are checking CONST_SCALAR_INT_P, you need to use
> > rtx_mode_t/wide_int instead.
> > Otherwise you change the check to CONST_INT_P and keep the UINTVAL.
> > As using CONST_WIDE_INT here can that will cause an ICE with RTL
> > checking and maybe even produce wrong code. E.g. using __int128.
> >
>
> > Can you add a comment before this mentioning each path down to 0 here?
> > Like say:
> > /*
> >   (x & c1) == c2 when c1 and c2 don't share any bits -> false
> >  */
> > ....
> >
>
> Done in v3: https://gcc.gnu.org/pipermail/gcc-patches/2026-April/712444.html

Will review soon.

>
> > I have not checked but are these also implemented in match.pd? If not
> > please file a bug report for them.
>
> Only the IOR eq/ne cases seems to be implemented in match.pd, though I wrote a
> simple C testcase and found out that all of the relevant comparisons were
> already optimized out after conditional constant propagation.  Should I file a
> bug report on match.pd?

If they are all handled by CCP it should be ok no reason to file a bug
there; I suspect the bits tracking part of CCP is optimizing them.
Most likely they will also be handled by ranger too.

Thanks,
Andrew

>
> Thanks,
> Bohan
>
>


More information about the Gcc-patches mailing list