[PATCH 09/22] sub: reorganize handling of OP_{ADD,SUB}s with constant rightside

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

 



This is a preparatory step for more interesting changes later.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 simplify.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/simplify.c b/simplify.c
index b14f88405861..f837b003efd4 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1101,6 +1101,7 @@ static int simplify_constant_rightside(struct instruction *insn)
 	long long value = insn->src2->value;
 	long long sbit = 1ULL << (insn->size - 1);
 	long long bits = sbit | (sbit - 1);
+	int changed = 0;
 
 	switch (insn->opcode) {
 	case OP_OR:
@@ -1113,20 +1114,21 @@ static int simplify_constant_rightside(struct instruction *insn)
 			insn->opcode = OP_NOT;
 			return REPEAT_CSE;
 		}
-		goto case_neutral_zero;
+		/* fallthrough */
+	case_neutral_zero:
+		if (!value)
+			return replace_with_pseudo(insn, insn->src1);
+		return 0;
 
 	case OP_SUB:
-		if (value) {
-			insn->opcode = OP_ADD;
-			insn->src2 = eval_unop(OP_NEG, insn->size, insn->src2);
-			return REPEAT_CSE;
-		}
-	/* Fall through */
+		insn->opcode = OP_ADD;
+		insn->src2 = eval_unop(OP_NEG, insn->size, insn->src2);
+		changed = REPEAT_CSE;
+		/* fallthrough */
 	case OP_ADD:
-	case_neutral_zero:
 		if (!value)
 			return replace_with_pseudo(insn, insn->src1);
-		return 0;
+		return changed;
 	case OP_ASR:
 	case OP_SHL:
 	case OP_LSR:
-- 
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