This adds four optimization patterns to match.pd, along with trivial test cases. Compiles and works as expected, and 'make check' on x86_64 gives the same number of "unexpected failures" before and after (8 from gfortran.dg/guality/pr41558.f90, 1 from failing to compile gcc.dg/plugin/ggcplug.c).
I know almost nothing about the internals of gcc, so 4/4 may very well be considered ugly - it was what I could stitch together from pieces I picked up here and there. Rasmus Villemoes (4): match.pd: Add x + (x & 1) -> (x + 1) & ~1 pattern match.pd: Add x & ~(x & y) -> x & ~y pattern match.pd: Add x | ~(x | y) -> x | ~y pattern match.pd: Add x + ((-x) & m) -> (x + m) & ~m pattern gcc/match.pd | 27 ++++++++++++++++++ gcc/testsuite/gcc.dg/20150120-1.c | 51 +++++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/20150120-2.c | 32 +++++++++++++++++++++ gcc/testsuite/gcc.dg/20150120-3.c | 32 +++++++++++++++++++++ gcc/testsuite/gcc.dg/20150120-4.c | 59 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 201 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/20150120-1.c create mode 100644 gcc/testsuite/gcc.dg/20150120-2.c create mode 100644 gcc/testsuite/gcc.dg/20150120-3.c create mode 100644 gcc/testsuite/gcc.dg/20150120-4.c -- 2.1.3