Currently, arithmetic right shifts with a shift count bigger than the operand size are simplified to zero. While this makes a lot of sense for LSR and SHL, for ASR it's much less so. Remove the simplification and let the back-end generate the code for a non-immediate count (which is what GCC do). Note: Some other options would be: - reduce the shift count module the operand size, like it was done previously at expansion time and which correspond to the run-time behaviour of several CPUs families (x86[-64], arm64, mips, ...) but not all of them (arm, ppc, ...). - truncate the count to N-1 Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 1 - validation/shift-undef.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 0c0f11349..d316367d8 100644 --- a/simplify.c +++ b/simplify.c @@ -547,7 +547,6 @@ static int simplify_asr(struct instruction *insn, pseudo_t pseudo, long long val if (value >= size && !insn->tainted) { warning(insn->pos, "right shift by bigger than source value"); insn->tainted = 1; - return replace_with_pseudo(insn, value_pseudo(0)); } if (!value) return replace_with_pseudo(insn, pseudo); diff --git a/validation/shift-undef.c b/validation/shift-undef.c index e15847a8e..df1ac89e6 100644 --- a/validation/shift-undef.c +++ b/validation/shift-undef.c @@ -98,6 +98,7 @@ shift-undef.c:18:30: warning: shift too big (4294967289) for type int shift-undef.c:19:30: warning: shift too big (4294967288) for type unsigned int shift-undef.c:20:30: warning: shift too big (4294967287) for type unsigned int shift-undef.c:21:29: warning: right shift by bigger than source value +shift-undef.c:24:29: warning: right shift by bigger than source value shift-undef.c:32:11: warning: shift too big (100) for type int shift-undef.c:33:11: warning: shift too big (101) for type unsigned int shift-undef.c:34:11: warning: shift too big (102) for type unsigned int @@ -117,5 +118,6 @@ shift-undef.c:47:30: warning: shift too big (4294967289) for type int shift-undef.c:48:30: warning: shift too big (4294967288) for type unsigned int shift-undef.c:49:30: warning: shift too big (4294967287) for type unsigned int shift-undef.c:50:26: warning: right shift by bigger than source value +shift-undef.c:53:26: warning: right shift by bigger than source value * check-error-end */ -- 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