diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-09-28 01:06:54 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-20 22:35:43 +0200 |
commit | 7a6b487222ab164c2501287fb6d3e0add10a3813 (patch) | |
tree | 5ad73a6770a0032f1893e85560fecbd72836e93a | |
parent | dbe0117ce6246725eaacc6ed3cb2b2c3ee14d1cc (diff) | |
download | sparse-7a6b487222ab164c2501287fb6d3e0add10a3813.tar.gz |
sub: simplify x - (y + x) --> -y
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | simplify.c | 2 | ||||
-rw-r--r-- | validation/optim/simplify-same-subr-add.c | 1 |
2 files changed, 2 insertions, 1 deletions
@@ -1399,6 +1399,8 @@ static int simplify_sub(struct instruction *insn) case OP_ADD: if (src1 == def->src1) // x - (x + z) --> -z return replace_with_unop(insn, OP_NEG, def->src2); + if (src1 == def->src2) // x - (y + x) --> -y + return replace_with_unop(insn, OP_NEG, def->src1); break; case OP_NEG: // (x - -y) --> (x + y) insn->opcode = OP_ADD; diff --git a/validation/optim/simplify-same-subr-add.c b/validation/optim/simplify-same-subr-add.c index bafd2643..950c55f6 100644 --- a/validation/optim/simplify-same-subr-add.c +++ b/validation/optim/simplify-same-subr-add.c @@ -3,7 +3,6 @@ int subr_add(int x, int y) { return x - (y + x); } /* * check-name: simplify-same-subr-add * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-contains: neg\\..* %arg2 |