Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 4 ++++ validation/optim/simplify-same-addl-sub.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 65fca35099a6..6caf6cbcf918 100644 --- a/simplify.c +++ b/simplify.c @@ -1380,6 +1380,10 @@ static int simplify_add(struct instruction *insn) case OP_NEG: // (x + -y) --> (x - y) insn->opcode = OP_SUB; return replace_pseudo(insn, &insn->src2, def->src); + case OP_SUB: + if (src1 == def->src2) // x + (y - x) --> y + return replace_with_pseudo(insn, def->src1); + break; } return 0; diff --git a/validation/optim/simplify-same-addl-sub.c b/validation/optim/simplify-same-addl-sub.c index 51d2b07966f4..9cca1d12ff92 100644 --- a/validation/optim/simplify-same-addl-sub.c +++ b/validation/optim/simplify-same-addl-sub.c @@ -3,7 +3,6 @@ int foo(int x, int y) { return x + (y - x); } /* * check-name: simplify-same-addl-sub * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-contains: ret\\..*%arg2 -- 2.28.0