Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 4 ++++ validation/optim/simplify-not-neg.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 1b6e1cc2313b..6588f8af2820 100644 --- a/simplify.c +++ b/simplify.c @@ -1470,6 +1470,10 @@ static int simplify_unop(struct instruction *insn) src = eval_unop(OP_NOT, insn->size, def->src2); use_pseudo(insn, def->src1, &insn->src2); return replace_pseudo(insn, &insn->src1, src); + case OP_NEG: + insn->opcode = OP_SUB; // ~(-x) --> x - 1 + insn->src2 = value_pseudo(1); + return replace_pseudo(insn, &insn->src1, def->src); case OP_NOT: // ~(~x) --> x return replace_with_pseudo(insn, def->src); case OP_SUB: diff --git a/validation/optim/simplify-not-neg.c b/validation/optim/simplify-not-neg.c index b9675ea62049..3fd8400d7bd4 100644 --- a/validation/optim/simplify-not-neg.c +++ b/validation/optim/simplify-not-neg.c @@ -3,7 +3,6 @@ int foo(int x) { return ~(-x) == (x - 1); } /* * check-name: simplify-not-neg * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-contains: ret\\..*\\$1 -- 2.28.0