[PATCH v3 09/15] move opcode test inside simplify_mask_or_and()

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

 



Calls to this function are guarded by a test checking
if the operand is defined by an OP_AND.

Move this guard inside the function as this make easier to
handle more opcodes later.

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

diff --git a/simplify.c b/simplify.c
index 2431a90cb..455860833 100644
--- a/simplify.c
+++ b/simplify.c
@@ -554,7 +554,7 @@ undef:
 // try to simplify OP(OR(AND(x, M'), b), K)
 // @insn: the 'masking' instruction
 // @mask: the mask associated to @insn (M)
-// @ora: one of the OR's operands
+// @ora: one of the OR's operands, guaranteed to be PSEUDO_REG
 // @orb: the other OR's operand
 // @return: 0 if no changes have been made, one or more REPEAT_* flags otherwise.
 static int simplify_mask_or_and(struct instruction *insn, unsigned long long mask,
@@ -564,6 +564,8 @@ static int simplify_mask_or_and(struct instruction *insn, unsigned long long mas
 	struct instruction *and = ora->def;
 	pseudo_t src2 = and->src2;
 
+	if (and->opcode != OP_AND)
+		return 0;
 	if (!constant(src2))
 		return 0;
 	omask = src2->value;
@@ -591,12 +593,14 @@ static int simplify_mask_or(struct instruction *insn, unsigned long long mask, s
 	pseudo_t src2 = or->src2;
 	int rc;
 
-	if (def_opcode(src1) == OP_AND)
+	if (src1->type == PSEUDO_REG) {
 		if ((rc = simplify_mask_or_and(insn, mask, src1, src2)))
 			return rc;
-	if (def_opcode(src2) == OP_AND)
+	}
+	if (src2->type == PSEUDO_REG) {
 		if ((rc = simplify_mask_or_and(insn, mask, src2, src1)))
 			return rc;
+	}
 	return 0;
 }
 
-- 
2.18.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