[PATCH 18/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                                | 2 ++
 validation/optim/simplify-same-add-subr.c | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/simplify.c b/simplify.c
index cb401d8fac9f..08b706ca8f41 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1390,6 +1390,8 @@ static int simplify_sub(struct instruction *insn)
 	case OP_ADD:
 		if (def->src1 == src2)		// (x + y) - x --> y
 			return replace_with_pseudo(insn, def->src2);
+		if (def->src2 == src2)		// (x + y) - y --> x
+			return replace_with_pseudo(insn, def->src1);
 		break;
 	}
 
diff --git a/validation/optim/simplify-same-add-subr.c b/validation/optim/simplify-same-add-subr.c
index e8540703ee7d..071021c485d7 100644
--- a/validation/optim/simplify-same-add-subr.c
+++ b/validation/optim/simplify-same-add-subr.c
@@ -3,7 +3,6 @@ int add_subr(int x, int y) { return (x + y) - y; }
 /*
  * check-name: simplify-same-add-subr
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-start
 add_subr:
-- 
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