Since an LSR with an in-range shift count will insert a zero in the MSB, a subsequent ASR will be equivalent to an LSR of the same count or equivalently, the combinaison the these two shifts is equivalent to a single LSR with a shift count equal to the sum of the two initial counts. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 7475d9e6c..322450b86 100644 --- a/simplify.c +++ b/simplify.c @@ -594,6 +594,7 @@ static int simplify_shift(struct instruction *insn, pseudo_t pseudo, long long v if (value >= size) return 0; switch(DEF_OPCODE(def, pseudo)) { + case OP_LSR: case OP_ASR: src2 = def->src2; if (src2->type != PSEUDO_VAL) @@ -602,7 +603,9 @@ static int simplify_shift(struct instruction *insn, pseudo_t pseudo, long long v if (nval > insn->size) break; value += nval; - if (value >= size) + if (def->opcode == OP_LSR) + insn->opcode = OP_LSR; + else if (value >= size) value = size - 1; goto new_value; } -- 2.18.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html