This bug is introduced by my commit r236181 where the inner rtx of SUBREG haven't been checked while it should as "in_class_p" only works with REG, and SUBREG_REG is actually not always REG. If REG_P check failed, then we should fall back to normal code patch. The following simple testcase for x86 can reproduce this bug.
long foo (long a) { return (unsigned) foo; } OK for trunk? x86-64 bootstrap OK and no regression on check-gcc/g++. 2016-05-17 Jiong Wang <jiong.w...@arm.com> gcc/ PR rtl-optimization/71150 * lra-constraint (process_addr_reg): Guard "in_class_p" with REG_P check.
diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 56ab5b4..e4e6c8c 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -1317,7 +1317,8 @@ process_addr_reg (rtx *loc, bool check_only_p, rtx_insn **before, rtx_insn **aft register, and this normally will be a subreg which should be reloaded as a whole. This is particularly likely to be triggered when -fno-split-wide-types specified. */ - if (in_class_p (reg, cl, &new_class) + if (!REG_P (reg) + || in_class_p (reg, cl, &new_class) || GET_MODE_SIZE (mode) <= GET_MODE_SIZE (ptr_mode)) loc = &SUBREG_REG (*loc); }