[PATCH 10/22] sub: canonicalize (0 - x) into -x

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

 



Not really a simplification in itself but it make some other
simplification a little easier (already because there is one
argument less to be matched).

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

diff --git a/simplify.c b/simplify.c
index f837b003efd4..aa0357d9e285 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1174,6 +1174,10 @@ static int simplify_constant_leftside(struct instruction *insn)
 		if (!value)
 			return replace_with_pseudo(insn, insn->src1);
 		return 0;
+	case OP_SUB:
+		if (!value)			// (0 - x) --> -x
+			return replace_with_unop(insn, OP_NEG, insn->src2);
+		break;
 	}
 	return 0;
 }
diff --git a/validation/optim/simplify-zero-sub.c b/validation/optim/simplify-zero-sub.c
index cc8fe7a3159b..70ce7c908844 100644
--- a/validation/optim/simplify-zero-sub.c
+++ b/validation/optim/simplify-zero-sub.c
@@ -3,7 +3,6 @@ int zero_sub(int x) { return 0 - x; }
 /*
  * check-name: simplify-zero-sub
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-contains: neg\\..* %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