These patches are a first set aiming at improving canonicalization and essential simplifications. Luc Van Oostenryck (22): add testcases about OP_ADD & OP_SUB simplifications let switch_pseudo() return REPEAT_CSE extract eval_op() from eval_insn() unop: add helper eval_unop() unop: add helper replace_with_unop() add a flag to identify commutative & associative ops constants must be truncated to the operation's size reassoc: simplify (x # C) # K --> x # eval(C # K) sub: reorganize handling of OP_{ADD,SUB}s with constant rightside sub: canonicalize (0 - x) into -x sub: simplify C - (y + D) --> eval(C-D) - y sub: simplify C - (D - z) --> z + eval(C-D) sub: simplify (C - y) + D --> eval(C+D) - y sub: simplify (x - -y) --> (x + y) add: simplify (x + -y) --> (x - y) add: simplify (-x + y) --> (y - x) sub: simplify (x + y) - x --> y sub: simplify (x + y) - y --> x sub: simplify x - (x + y) --> -y sub: simplify x - (y + x) --> -y sub: simplify (x - y) + y --> x sub: simplify x + (y - x) --> y opcode.def | 50 ++--- opcode.h | 5 + simplify.c | 250 ++++++++++++++++++---- validation/optim/canonical-sub-cte.c | 9 + validation/optim/reassoc-op-op1.c | 14 ++ validation/optim/simplify-add-neg.c | 9 + validation/optim/simplify-cte-sub-addl.c | 9 + validation/optim/simplify-cte-sub-addr.c | 9 + validation/optim/simplify-cte-sub-subr.c | 9 + validation/optim/simplify-neg-add.c | 9 + validation/optim/simplify-same-add-subl.c | 15 ++ validation/optim/simplify-same-add-subr.c | 15 ++ validation/optim/simplify-same-addl-sub.c | 9 + validation/optim/simplify-same-sub-addl.c | 9 + validation/optim/simplify-same-subl-add.c | 11 + validation/optim/simplify-same-subr-add.c | 11 + validation/optim/simplify-sub-neg.c | 9 + validation/optim/simplify-zero-sub.c | 9 + 18 files changed, 397 insertions(+), 64 deletions(-) create mode 100644 validation/optim/canonical-sub-cte.c create mode 100644 validation/optim/reassoc-op-op1.c create mode 100644 validation/optim/simplify-add-neg.c create mode 100644 validation/optim/simplify-cte-sub-addl.c create mode 100644 validation/optim/simplify-cte-sub-addr.c create mode 100644 validation/optim/simplify-cte-sub-subr.c create mode 100644 validation/optim/simplify-neg-add.c create mode 100644 validation/optim/simplify-same-add-subl.c create mode 100644 validation/optim/simplify-same-add-subr.c create mode 100644 validation/optim/simplify-same-addl-sub.c create mode 100644 validation/optim/simplify-same-sub-addl.c create mode 100644 validation/optim/simplify-same-subl-add.c create mode 100644 validation/optim/simplify-same-subr-add.c create mode 100644 validation/optim/simplify-sub-neg.c create mode 100644 validation/optim/simplify-zero-sub.c base-commit: 5192dc1ff23dae8644480a89ada8ff420ebb674a -- 2.28.0