mbox series

[0/7] simplify logical negation

Message ID 20201122152731.10994-1-luc.vanoostenryck@gmail.com (mailing list archive)
Headers show
Series simplify logical negation | expand

Message

Luc Van Oostenryck Nov. 22, 2020, 3:27 p.m. UTC
This series contains simplifications for tautologies and
contradictions involving logical negation, like (~x & x)
or ((x > y) | (x <= y)).

As a bonus (but needed for these simplifications), now
PSEUDO_REGs and PSEUDO_ARGs are also taken in account when
checking if operands are in canonical order, which creates
a few CSE opportunities of its own.


Luc Van Oostenryck (7):
  not: add testcases for canonicalization & simplification of negations
  canon: put PSEUDO_ARGs in canonical order too
  canon: put PSEUDO_REGs in canonical order too
  canon: simplify calculation of canonical order
  opcode: add helpers opcode_negate() & opcode_swap()
  not: simplify (~x {&,|,^} x) --> {0,~0,~0}
  not: simplify ((x cmp y) {&,|,^} (x !cmp y)) --> {0,1,1}

 linearize.h                         |   4 +-
 opcode.h                            |  10 +++
 simplify.c                          | 118 +++++++++++++++++++++++++---
 validation/linear/pointer-arith32.c |  12 +--
 validation/linear/pointer-arith64.c |  10 +--
 validation/optim/canonical-arg.c    |  20 +++++
 validation/optim/canonical-not.c    |   9 +++
 validation/optim/cse-arg01.c        |   9 +++
 validation/optim/cse-not01.c        |  11 +++
 validation/optim/cse-not02.c        |  11 +++
 validation/optim/cse-reg01.c        |   9 +++
 11 files changed, 200 insertions(+), 23 deletions(-)
 create mode 100644 validation/optim/canonical-arg.c
 create mode 100644 validation/optim/canonical-not.c
 create mode 100644 validation/optim/cse-arg01.c
 create mode 100644 validation/optim/cse-not01.c
 create mode 100644 validation/optim/cse-not02.c
 create mode 100644 validation/optim/cse-reg01.c