aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-11-26 23:25:30 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:05:02 -0700
commit10c21653c1648fb7619ebe8f9787365d78574a11 (patch)
tree76eae6890503615ad1baddeb7e76aba6c4c1035e /simplify.c
parentBe a lot more careful when re-writing branches. (diff)
downloadsparse-10c21653c1648fb7619ebe8f9787365d78574a11.tar.gz
sparse-10c21653c1648fb7619ebe8f9787365d78574a11.tar.bz2
sparse-10c21653c1648fb7619ebe8f9787365d78574a11.zip
Simplify constant subtraction into addition.
We're much better at simplifying addition, so let's try to fix it up.
Diffstat (limited to 'simplify.c')
-rw-r--r--simplify.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/simplify.c b/simplify.c
index 3d7cd72..85c04c1 100644
--- a/simplify.c
+++ b/simplify.c
@@ -233,7 +233,14 @@ static int simplify_constant_rightside(struct instruction *insn)
long long value = insn->src2->value;
switch (insn->opcode) {
- case OP_ADD: case OP_SUB:
+ case OP_SUB:
+ if (value) {
+ insn->opcode = OP_ADD;
+ insn->src2 = value_pseudo(-value);
+ return REPEAT_CSE;
+ }
+ /* Fallthrough */
+ case OP_ADD:
case OP_OR: case OP_XOR:
case OP_SHL: case OP_SHR:
if (!value)