diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-08-29 20:51:30 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-24 22:57:44 +0200 |
commit | f28372ddc5f19bbed4fbd6cff33bb111a4261ce7 (patch) | |
tree | fe7dfe1ceea2d3679a2885d6ec7343dfc333c465 | |
parent | 9577415162562118976aef3d5c11765882186366 (diff) | |
download | sparse-f28372ddc5f19bbed4fbd6cff33bb111a4261ce7.tar.gz |
unop: simplify -(~x) --> x + 1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | simplify.c | 4 | ||||
-rw-r--r-- | validation/optim/simplify-neg-not.c | 1 |
2 files changed, 4 insertions, 1 deletions
@@ -1477,6 +1477,10 @@ static int simplify_unop(struct instruction *insn) return replace_pseudo(insn, &insn->src1, src); case OP_NEG: // -(-x) --> x return replace_with_pseudo(insn, def->src); + case OP_NOT: + insn->opcode = OP_ADD; // -(~x) --> x + 1 + insn->src2 = value_pseudo(1); + return replace_pseudo(insn, &insn->src1, def->src); case OP_SUB: insn->opcode = OP_SUB; // -(x - y) --> y - x use_pseudo(insn, def->src1, &insn->src2); diff --git a/validation/optim/simplify-neg-not.c b/validation/optim/simplify-neg-not.c index 4bd0abfb..e92352cf 100644 --- a/validation/optim/simplify-neg-not.c +++ b/validation/optim/simplify-neg-not.c @@ -3,7 +3,6 @@ int foo(int x) { return -(~x) == x + 1; } /* * check-name: simplify-neg-not * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-contains: ret\\..*\\$1 |