Index: combine.c =================================================================== --- combine.c (revision 191681) +++ combine.c (working copy) @@ -5314,6 +5314,26 @@ combine_simplify_rtx (rtx x, enum machine_mode op0 break; case RTX_COMM_ARITH: case RTX_BIN_ARITH: + if ((code == PLUS || code == MINUS) + && GET_MODE_CLASS (mode) == MODE_INT + && HWI_COMPUTABLE_MODE_P (mode)) + { + /* Adjust operands in the form of (subreg:M (op:N A C) 0) + to (op:M (subreg:N (A 0)) C). This transformation + generates canonical (plus:M (plus:M (subreg:N (A 0) C1) C2)) + RTXes that can be recognized and further optimized by + simplify_plus_minus. */ + if (GET_CODE (XEXP (x, 0)) == SUBREG + && plus_minus_operand_p (SUBREG_REG (XEXP (x, 0)))) + SUBST (XEXP (x, 0), + force_to_mode (XEXP (x, 0), mode, + ~(unsigned HOST_WIDE_INT) 0, 0)); + if (GET_CODE (XEXP (x, 1)) == SUBREG + && plus_minus_operand_p (SUBREG_REG (XEXP (x, 1)))) + SUBST (XEXP (x, 1), + force_to_mode (XEXP (x, 1), mode, + ~(unsigned HOST_WIDE_INT) 0, 0)); + } temp = simplify_binary_operation (code, mode, XEXP (x, 0), XEXP (x, 1)); break; case RTX_BITFIELD_OPS: Index: rtl.h =================================================================== --- rtl.h (revision 191681) +++ rtl.h (working copy) @@ -1895,6 +1895,7 @@ extern bool val_signbit_known_set_p (enum machine_ unsigned HOST_WIDE_INT); extern bool val_signbit_known_clear_p (enum machine_mode, unsigned HOST_WIDE_INT); +extern bool plus_minus_operand_p (const_rtx); /* In reginfo.c */ extern enum machine_mode choose_hard_reg_mode (unsigned int, unsigned int, Index: simplify-rtx.c =================================================================== --- simplify-rtx.c (revision 191681) +++ simplify-rtx.c (working copy) @@ -48,7 +48,6 @@ along with GCC; see the file COPYING3. If not see ((((HOST_WIDE_INT) low) < 0) ? ((HOST_WIDE_INT) -1) : ((HOST_WIDE_INT) 0)) static rtx neg_const_int (enum machine_mode, const_rtx); -static bool plus_minus_operand_p (const_rtx); static bool simplify_plus_minus_op_data_cmp (rtx, rtx); static rtx simplify_plus_minus (enum rtx_code, enum machine_mode, rtx, rtx); static rtx simplify_immed_subreg (enum machine_mode, rtx, enum machine_mode, @@ -4186,7 +4185,7 @@ simplify_plus_minus (enum rtx_code code, enum mach } /* Check whether an operand is suitable for calling simplify_plus_minus. */ -static bool +bool plus_minus_operand_p (const_rtx x) { return GET_CODE (x) == PLUS