[PATCH 12/22] sub: simplify C - (D - z) --> z + eval(C-D)

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

 



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

diff --git a/simplify.c b/simplify.c
index b97354bc40cc..7d1897e65b07 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1169,6 +1169,14 @@ static int simplify_const_leftsub(struct instruction *insn, struct instruction *
 			return replace_pseudo(insn, &insn->src2, def->src1);
 		}
 		break;
+	case OP_SUB:
+		if (constant(def->src1)) { // C - (D - z) --> z + eval(C-D)
+			pseudo_t val = eval_op(OP_SUB, size, src1, def->src1);
+			insn->opcode = OP_ADD;
+			use_pseudo(insn, def->src2, &insn->src1);
+			return replace_pseudo(insn, &insn->src2, val);
+		}
+		break;
 	}
 	return 0;
 }
diff --git a/validation/optim/simplify-cte-sub-subr.c b/validation/optim/simplify-cte-sub-subr.c
index 950b233e60c3..10fdbbc82933 100644
--- a/validation/optim/simplify-cte-sub-subr.c
+++ b/validation/optim/simplify-cte-sub-subr.c
@@ -3,7 +3,6 @@ int cte_sub_subr(int x) { return 1 - (1 - x); }
 /*
  * check-name: simplify-cte-sub-subr
  * 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