Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 6 ++++++ validation/optim/simplify-not-sub-cte.c | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 63431b3d00b1..8173777652af 100644 --- a/simplify.c +++ b/simplify.c @@ -1472,6 +1472,12 @@ static int simplify_unop(struct instruction *insn) return replace_pseudo(insn, &insn->src1, src); case OP_NOT: // ~(~x) --> x return replace_with_pseudo(insn, def->src); + case OP_SUB: + if (!constant(def->src1)) + break; + insn->opcode = OP_ADD; // ~(C - x) --> x + ~C + insn->src2 = eval_unop(OP_NOT, insn->size, def->src1); + return replace_pseudo(insn, &insn->src1, def->src2); } break; case OP_NEG: diff --git a/validation/optim/simplify-not-sub-cte.c b/validation/optim/simplify-not-sub-cte.c index ec105beb31fe..1ea73ece2e27 100644 --- a/validation/optim/simplify-not-sub-cte.c +++ b/validation/optim/simplify-not-sub-cte.c @@ -5,7 +5,6 @@ int foo(int x) { return ~(C - x) == (x + ~C); } /* * check-name: simplify-not-sub-cte * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-contains: ret\\..*\\$1 -- 2.28.0