match: Simplify `1 >> x` into `x == 0` [PR102705]
This in this PR we have missed optimization where we miss that,
`1 >> x` and `(1 >> x) ^ 1` can't be equal. There are a few ways of
optimizing this, the easiest and simpliest is to simplify `1 >> x` into
just `x == 0` as those are equivalant (if we ignore out of range values for x).
we already have an optimization for `(1 >> X) !=/== 0` so the only difference
here is we don't need the `!=/== 0` part to do the transformation.
So this removes the `(1 >> X) !=/== 0` transformation and just adds a simplfied
`1 >> x` -> `x == 0` one.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/102705
gcc/ChangeLog:
* match.pd (`(1 >> X) != 0`): Remove pattern.
(`1 >> x`): New pattern.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr105832-2.c: Update testcase.
* gcc.dg/tree-ssa/pr96669-1.c: Likewise.
* gcc.dg/tree-ssa/pr102705-1.c: New test.
* gcc.dg/tree-ssa/pr102705-2.c: New test.
Signed-off-by:
Andrew Pinski <quic_apinski@quicinc.com>
Showing
- gcc/match.pd 8 additions, 8 deletionsgcc/match.pd
- gcc/testsuite/gcc.dg/tree-ssa/pr102705-1.c 17 additions, 0 deletionsgcc/testsuite/gcc.dg/tree-ssa/pr102705-1.c
- gcc/testsuite/gcc.dg/tree-ssa/pr102705-2.c 17 additions, 0 deletionsgcc/testsuite/gcc.dg/tree-ssa/pr102705-2.c
- gcc/testsuite/gcc.dg/tree-ssa/pr105832-2.c 4 additions, 4 deletionsgcc/testsuite/gcc.dg/tree-ssa/pr105832-2.c
- gcc/testsuite/gcc.dg/tree-ssa/pr96669-1.c 1 addition, 1 deletiongcc/testsuite/gcc.dg/tree-ssa/pr96669-1.c
Loading
Please register or sign in to comment