Konstantinos Eleftheriou <konstantinos.elefther...@vrull.eu> writes: > From: kelefth <konstantinos.elefther...@vrull.eu> > > In expressions like (a != b || ((a ^ b) & CST0) == CST1) and > (a != b || (a ^ b) == CST), (a ^ b) is folded to false. > In the equivalent expressions (((a ^ b) & CST0) == CST1 || a != b) and > ((a ^ b) == CST, (a ^ b) || a != b) this is not happening. > > This patch adds the following simplifications in match.pd: > ((a ^ b) & CST0) == CST1 || a != b --> 0 == (CST1 || a != b) > (a ^ b) == CST || a != b --> 0 == CST || (a != b) > > PR tree-optimization/114326 > > gcc/ChangeLog: > > * match.pd: Add two patterns to fold a ^ b to 0, when a == b. > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/fold-xor-and-or-1.c: New test. > * gcc.dg/tree-ssa/fold-xor-and-or-2.c: New test. > * gcc.dg/tree-ssa/fold-xor-or-1.c: New test. > * gcc.dg/tree-ssa/fold-xor-or-2.c: New test. > > Reviewed-by: Christoph Müllner <christoph.muell...@vrull.eu> > Signed-off-by: Philipp Tomsich <philipp.toms...@vrull.eu> > Signed-off-by: Konstantinos Eleftheriou <konstantinos.elefther...@vrull.eu> > --- > gcc/match.pd | 30 +++++++++++++++++++ > .../gcc.dg/tree-ssa/fold-xor-and-or-1.c | 17 +++++++++++ > .../gcc.dg/tree-ssa/fold-xor-and-or-2.c | 19 ++++++++++++ > gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or-1.c | 17 +++++++++++ > gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or-2.c | 19 ++++++++++++ > 5 files changed, 102 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/fold-xor-and-or-1.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/fold-xor-and-or-2.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or-1.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or-2.c > > [...] > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-and-or-2.c > @@ -0,0 +1,19 @@ > +/* { dg-do-compile } */
/* { dg-do compile } */ Please fix each instance of that. Thanks! > [...] sam
signature.asc
Description: PGP signature