aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/simplify.c
diff options
Diffstat (limited to 'simplify.c')
-rw-r--r--simplify.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/simplify.c b/simplify.c
index 65fca350..6caf6cbc 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;