[PATCH 21/22] sub: simplify (x - y) + y --> x

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 simplify.c                                | 5 +++++
 validation/optim/simplify-same-sub-addl.c | 1 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/simplify.c b/simplify.c
index 68ee6ed015c1..65fca35099a6 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1369,6 +1369,11 @@ static int simplify_add(struct instruction *insn)
 		switch_pseudo(insn, &insn->src1, insn, &insn->src2);
 		insn->opcode = OP_SUB;
 		return replace_pseudo(insn, &insn->src2, def->src);
+
+	case OP_SUB:
+		if (def->src2 == src2)		// (x - y) + y --> x
+			return replace_with_pseudo(insn, def->src1);
+		break;
 	}
 
 	switch (DEF_OPCODE(def, src2)) {
diff --git a/validation/optim/simplify-same-sub-addl.c b/validation/optim/simplify-same-sub-addl.c
index 78f217399e50..56b6fcc24e9d 100644
--- a/validation/optim/simplify-same-sub-addl.c
+++ b/validation/optim/simplify-same-sub-addl.c
@@ -3,7 +3,6 @@ int foo(int x, int y) { return (x - y) + y; }
 /*
  * check-name: simplify-same-sub-addl
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-contains: ret\\..*%arg1
-- 
2.28.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux