diff options
| -rw-r--r-- | simplify.c | 7 | ||||
| -rw-r--r-- | validation/optim/simplify-neg-add-cte.c | 1 |
2 files changed, 7 insertions, 1 deletions
@@ -1468,6 +1468,13 @@ static int simplify_unop(struct instruction *insn) break; case OP_NEG: switch (DEF_OPCODE(def, src)) { + case OP_ADD: + if (!constant(def->src2)) + break; + insn->opcode = OP_SUB; // -(x + C) --> (-C - x) + src = eval_unop(OP_NEG, insn->size, def->src2); + use_pseudo(insn, def->src1, &insn->src2); + return replace_pseudo(insn, &insn->src1, src); case OP_NEG: // -(-x) --> x return replace_with_pseudo(insn, def->src); } diff --git a/validation/optim/simplify-neg-add-cte.c b/validation/optim/simplify-neg-add-cte.c index 4e425096..a02c474f 100644 --- a/validation/optim/simplify-neg-add-cte.c +++ b/validation/optim/simplify-neg-add-cte.c @@ -5,7 +5,6 @@ int foo(int x) { return -(x + C) == (-3 - x); } /* * check-name: simplify-neg-add-cte * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-contains: ret\\..*\\$1 |
