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

[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-subr-add.c | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/simplify.c b/simplify.c
index 48bf48d29f9a..68ee6ed015c1 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1399,6 +1399,8 @@ static int simplify_sub(struct instruction *insn)
 	case OP_ADD:
 		if (src1 == def->src1)		// x - (x + z) --> -z
 			return replace_with_unop(insn, OP_NEG, def->src2);
+		if (src1 == def->src2)		// x - (y + x) --> -y
+			return replace_with_unop(insn, OP_NEG, def->src1);
 		break;
 	case OP_NEG:				// (x - -y) --> (x + y)
 		insn->opcode = OP_ADD;
diff --git a/validation/optim/simplify-same-subr-add.c b/validation/optim/simplify-same-subr-add.c
index bafd2643bfd0..950c55f67c24 100644
--- a/validation/optim/simplify-same-subr-add.c
+++ b/validation/optim/simplify-same-subr-add.c
@@ -3,7 +3,6 @@ int subr_add(int x, int y) { return x - (y + x); }
 /*
  * check-name: simplify-same-subr-add
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-contains: neg\\..* %arg2
-- 
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