Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 7 +++++++ validation/optim/simplify-not-add-cte.c | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 8f6b821dcf8c..63431b3d00b1 100644 --- a/simplify.c +++ b/simplify.c @@ -1463,6 +1463,13 @@ static int simplify_unop(struct instruction *insn) case OP_NOT: 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_NOT, insn->size, def->src2); + use_pseudo(insn, def->src1, &insn->src2); + return replace_pseudo(insn, &insn->src1, src); case OP_NOT: // ~(~x) --> x return replace_with_pseudo(insn, def->src); } diff --git a/validation/optim/simplify-not-add-cte.c b/validation/optim/simplify-not-add-cte.c index cf7fe2f27258..6594012b5077 100644 --- a/validation/optim/simplify-not-add-cte.c +++ b/validation/optim/simplify-not-add-cte.c @@ -5,7 +5,6 @@ int foo(int x) { return ~(x + C) == (~C - x); } /* * check-name: simplify-not-add-cte * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-contains: ret\\..*\\$1 -- 2.28.0