If the compiled program does a shift by a negative amount, combine will happily work with that, but it shouldn't then do an undefined operation in GCC itself. This patch fixes the first case mentioned in the bug report (I haven't been able to reproduce the second case, on trunk at least).
Bootstrapped and tested on powerpc64-linux, committing to trunk. Segher 2016-05-13 Segher Boessenkool <seg...@kernel.crashing.org> PR rtl-optimization/67483 * combine.c (make_compound_operation): Don't call extract_left_shift with negative shift amounts. --- gcc/combine.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/combine.c b/gcc/combine.c index 02aadc4..b819415 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -8071,6 +8071,7 @@ make_compound_operation (rtx x, enum rtx_code in_code) && ! (GET_CODE (lhs) == SUBREG && (OBJECT_P (SUBREG_REG (lhs)))) && CONST_INT_P (rhs) + && INTVAL (rhs) >= 0 && INTVAL (rhs) < HOST_BITS_PER_WIDE_INT && INTVAL (rhs) < mode_width && (new_rtx = extract_left_shift (lhs, INTVAL (rhs))) != 0) -- 1.9.3