match.pd: Generalize the PR64309 simplifications [PR96669]
authorJakub Jelinek <jakub@redhat.com>
Fri, 15 Jan 2021 20:12:14 +0000 (21:12 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 15 Jan 2021 20:12:14 +0000 (21:12 +0100)
commit0425f4c1b63107bf3bc4778d1fe53c91ace7838d
tree48f0ca415fb19a52b755cefdd92d0434efee9831
parent5c046034e3ea61dd68965154a398f8f813daf8f2
match.pd: Generalize the PR64309 simplifications [PR96669]

The following patch generalizes the PR64309 simplifications, so that instead
of working only with constants 1 and 1 it works with any two power of two
constants, and works also for right shift (in that case it rules out the
first one being negative, as it is arithmetic shift then).

2021-01-15  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/96669
* match.pd (((1 << A) & 1) != 0 -> A == 0,
((1 << A) & 1) == 0 -> A != 0): Generalize for 1s replaced by
possibly different power of two constants and to right shift too.

* gcc.dg/tree-ssa/pr96669-1.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/pr96669-1.c [new file with mode: 0644]