On Mon, Nov 6, 2017 at 10:35 PM, Marc Glisse <marc.gli...@inria.fr> wrote: > Hello, > > those have been on my TODO-list for a long time (found in LLVM IIRC). We > were not doing any of those transformations, even in GENERIC, so nothing to > remove from fold-const.c. The idea is that any expression involving only 2 > variables and operators &|^~ should simplify to at most 2 insn (modulo some > single_use issues), not sure if we are there yet. The second transformation > became almost redundant when I added the last canonicalization, but since > the (rather arbitrary) single_use checks are not the same, I left it. The > number of transformations on bit operations in match.pd is large (and I > still have some on that TODO-list), if someone can think of a nice way to > organize them, please go ahead.
I wonder if the reassoc pass handles this (I doubt). The reassoc pass IIRC only handles chains of same operations and for simplification doesn't try to use match-and-simplify (one can look at tree-ssa-sccvn.c how to try simplifying an expression that doesn't have a GIMPLE stmt but operands with GIMPLE stmts). And yes - ordering / arranging patterns in match.pd can be somewhat iffy. Very originally I had a split file with #includes, maybe at some point we want to go back to this. > I was tempted to use C++ templates for the testcase... ;) Ok. Thanks, Richard. > Bootstrap+regtest on powerpc64le-unknown-linux-gnu. > > 2017-11-07 Marc Glisse <marc.gli...@inria.fr> > > gcc/ > * match.pd ((a&~b)|(a^b),(a&~b)^~a,(a|b)&~(a^b),a|~(a^b), > (a|b)|(a&^b),(a&b)|~(a^b),~(~a&b),~X^Y): New transformations. > > gcc/testsuite/ > * gcc.dg/tree-ssa/bitops-1.c: New file. > > -- > Marc Glisse