aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-08 00:48:06 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-22 09:25:34 +0200
commita82cde96cb4bdedac5678c37be1d80b2dc7fab88 (patch)
tree049ad6652e9bd9735fae7cf6cd0af1fc6b5f2ed3
parent8b8a5e5501bb130900f0007126d283119512b286 (diff)
downloadsparse-dev-a82cde96cb4bdedac5678c37be1d80b2dc7fab88.tar.gz
move opcode test inside simplify_mask_or_and()
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@gmail.com>
-rw-r--r--simplify.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/simplify.c b/simplify.c
index dd569007..c12655d1 100644
--- a/simplify.c
+++ b/simplify.c
@@ -585,7 +585,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,
@@ -595,6 +595,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;
@@ -622,12 +624,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;
}