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

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

 



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

diff --git a/simplify.c b/simplify.c
index 08b706ca8f41..48bf48d29f9a 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1396,6 +1396,10 @@ static int simplify_sub(struct instruction *insn)
 	}
 
 	switch (DEF_OPCODE(def, src2)) {
+	case OP_ADD:
+		if (src1 == def->src1)		// x - (x + z) --> -z
+			return replace_with_unop(insn, OP_NEG, def->src2);
+		break;
 	case OP_NEG:				// (x - -y) --> (x + y)
 		insn->opcode = OP_ADD;
 		return replace_pseudo(insn, &insn->src2, def->src);
diff --git a/validation/optim/simplify-same-subl-add.c b/validation/optim/simplify-same-subl-add.c
index dbc0fe97f126..e7ae08092556 100644
--- a/validation/optim/simplify-same-subl-add.c
+++ b/validation/optim/simplify-same-subl-add.c
@@ -3,7 +3,6 @@ int subl_add(int x, int y) { return x - (x + y); }
 /*
  * check-name: simplify-same-subl-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