@@ -1,5 +1,12 @@
2011-03-01 H.J. Lu <hongjiu.lu@intel.com>
+ PR target/47744
+ * config/i386/i386.c (ix86_simplify_base_disp): Add PLUS base
+ support.
+ (ix86_decompose_address): Updated.
+
+2011-03-01 H.J. Lu <hongjiu.lu@intel.com>
+
PR target/47926
* config/i386/i386.c (ix86_trampoline_init): Use movl instead
of movabs for x32.
@@ -11620,10 +11620,26 @@ ix86_live_on_entry (bitmap regs)
(const_int 8))
(reg/f:SI 7 sp))
(const_int [CONST1 + CONST2])))
- */
+
+ If PLUS is true, we also translate
+
+ (set (reg:SI 40 r11)
+ (plus:SI (plus:SI (reg:SI 1 dx)
+ (subreg:SI (plus:DI (reg/f:DI 7 sp)
+ (const_int CONST1)) 0))
+ (const_int CONST2)))
+
+ into
+
+ (set (reg:SI 40 r11)
+ (plus:SI (plus:SI (reg:SI 1 dx)
+ (reg/f:SI 7 sp))
+ (const_int [CONST1 + CONST2])))
+
+ */
static void
-ix86_simplify_base_disp (rtx *base_p, rtx *disp_p)
+ix86_simplify_base_disp (rtx *base_p, rtx *disp_p, bool plus)
{
rtx base = *base_p;
rtx disp;
@@ -11649,13 +11665,33 @@ ix86_simplify_base_disp (rtx *base_p, rtx *disp_p)
if (REG_P (op0) && CONST_INT_P (op1))
{
base = op0;
- addend = op1;
+ addend = op1;
}
else if (REG_P (op1) && CONST_INT_P (op0))
{
base = op1;
addend = op0;
}
+ else if (plus
+ && GET_CODE (op1) == SUBREG
+ && GET_MODE (op1) == ptr_mode)
+ {
+ op1 = SUBREG_REG (op1);
+ if (GET_CODE (op1) == PLUS)
+ {
+ addend = XEXP (op1, 1);
+ op1 = XEXP (op1, 0);
+ if (REG_P (op1) && CONST_INT_P (addend))
+ {
+ op1 = gen_rtx_REG (ptr_mode, REGNO (op1));
+ *base_p = gen_rtx_PLUS (ptr_mode, op0, op1);
+ }
+ else
+ return;
+ }
+ else
+ return;
+ }
else
return;
@@ -11664,7 +11700,8 @@ ix86_simplify_base_disp (rtx *base_p, rtx *disp_p)
else
*disp_p = GEN_INT (INTVAL (disp) + INTVAL (addend));
- *base_p = gen_rtx_REG (ptr_mode, REGNO (base));
+ if (!plus)
+ *base_p = gen_rtx_REG (ptr_mode, REGNO (base));
}
}
@@ -11706,15 +11743,20 @@ ix86_decompose_address (rtx addr, struct ix86_address *out)
addends[n++] = XEXP (op, 1);
op = XEXP (op, 0);
/* Support 32bit address in x32 mode. */
- if (TARGET_X32
- && reload_completed
- && GET_CODE (op) == ZERO_EXTEND
- && GET_MODE (op) == Pmode
- && GET_CODE (XEXP (op, 0)) == PLUS)
+ if (TARGET_X32 && reload_completed)
{
- op = XEXP (op, 0);
- if (n == 1)
- ix86_simplify_base_disp (&op, &addends[0]);
+ if (GET_CODE (op) == ZERO_EXTEND
+ && GET_MODE (op) == Pmode
+ && GET_CODE (XEXP (op, 0)) == PLUS)
+ {
+ op = XEXP (op, 0);
+ if (n == 1)
+ ix86_simplify_base_disp (&op, &addends[0], false);
+ }
+ else if (n == 1
+ && GET_CODE (op) == PLUS
+ && GET_MODE (op) == ptr_mode)
+ ix86_simplify_base_disp (&op, &addends[0], true);
}
}
while (GET_CODE (op) == PLUS);
@@ -11816,7 +11858,7 @@ ix86_decompose_address (rtx addr, struct ix86_address *out)
disp = NULL_RTX;
if (TARGET_X32 && reload_completed)
- ix86_simplify_base_disp (&base, &disp);
+ ix86_simplify_base_disp (&base, &disp, false);
base_reg = base && GET_CODE (base) == SUBREG ? SUBREG_REG (base) : base;
@@ -1,3 +1,8 @@
+2011-03-01 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/47744
+ * gcc.dg/torture/pr47744-3.c: New.
+
2011-02-19 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/47364
new file mode 100644
@@ -0,0 +1,74 @@
+/* { dg-do compile } */
+
+typedef union rtunion_def {
+ struct rtx_def *rtx;
+} rtunion;
+typedef struct rtx_def {
+ unsigned short code;
+ rtunion fld[1];
+} *rtx;
+extern rtx recog_operand[];
+extern rtx *recog_operand_loc[];
+extern int reload_n_operands;
+extern void find_dummy_reload (int, int);
+extern int asm_noperands (rtx);
+extern int n_occurrences (char **);
+char operands_match[10][10];
+void find_reloads (rtx insn, int n_alternatives, int commutative)
+{
+ register int i, j;
+ int noperands;
+ char *constraints[10];
+ int address_reloaded[10];
+ int this_alternative[10];
+ char this_alternative_win[10];
+ int this_alternative_matches[10];
+ int this_alternative_number;
+ rtx body = ((insn)->fld[3].rtx);
+ int operand_mode[10];
+ if (body->code == 1)
+ {
+ reload_n_operands = noperands = asm_noperands (body);
+ n_alternatives = n_occurrences (constraints);
+ }
+ for (this_alternative_number = 0;
+ this_alternative_number < n_alternatives;
+ this_alternative_number++)
+ for (i = 0;
+ i < noperands;
+ i++)
+ {
+ register char *p = constraints[i];
+ register int win = 0;
+ int badop = 1;
+ int c;
+ register rtx operand = recog_operand[i];
+ int force_reload = 0;
+ this_alternative_win[i] = 0;
+ this_alternative[i] = 1;
+ while (*p && (c = *p++) != ',')
+ switch (c)
+ {
+ case '4':
+ c -= '0';
+ this_alternative_matches[i] = c;
+ if ((c != commutative
+ || i != commutative + 1)
+ && operands_match[c][i])
+ win = this_alternative_win[c];
+ else
+ find_dummy_reload (operand_mode[i], this_alternative[c]);
+ if (! win || force_reload)
+ for (j = 0; j < i; j++)
+ if (this_alternative_matches[j]
+ == this_alternative_matches[i])
+ badop = 1;
+ break;
+ case '<':
+ if (operand->code == 2
+ && ! address_reloaded[i]
+ && operand->fld[0].rtx->code == 3)
+ win = 1;
+ }
+ }
+}