diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-08 00:48:06 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-22 09:25:34 +0200 |
| commit | a82cde96cb4bdedac5678c37be1d80b2dc7fab88 (patch) | |
| tree | 049ad6652e9bd9735fae7cf6cd0af1fc6b5f2ed3 | |
| parent | 8b8a5e5501bb130900f0007126d283119512b286 (diff) | |
| download | sparse-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.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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; } |
