+2012-08-06 Uros Bizjak <ubizjak@gmail.com>
+
+ Backport from mainline
+ 2012-07-23 Uros Bizjak <ubizjak@gmail.com>
+
+ * config/i386/i386-protos.h (ix86_lea_outperforms): Remove prototype.
+ * config/i386/i386.c (ix86_lea_outperforms): Make static. Make
+ split_cost argument signed.
+ (ix86_use_lea_for_mov): Use INVALID_REGNUM instead of -1.
+ (ix86_avoid_lea_for_addr): Ditto.
+
+ 2012-07-27 Uros Bizjak <ubizjak@gmail.com>
+
+ * config/i386/i386.c (ix86_avoid_lea_for_addr): Return false if
+ the address has less than two components.
+
2012-08-02 Steve Ellcey <sellcey@mips.com>
Backport from mainline
extern void ix86_expand_binary_operator (enum rtx_code,
enum machine_mode, rtx[]);
extern bool ix86_binary_operator_ok (enum rtx_code, enum machine_mode, rtx[]);
-extern bool ix86_lea_outperforms (rtx, unsigned int, unsigned int,
- unsigned int, unsigned int);
extern bool ix86_avoid_lea_for_add (rtx, rtx[]);
extern bool ix86_use_lea_for_mov (rtx, rtx[]);
extern bool ix86_avoid_lea_for_addr (rtx, rtx[]);
over a sequence of instructions. Instructions sequence has
SPLIT_COST cycles higher latency than lea latency. */
-bool
+static bool
ix86_lea_outperforms (rtx insn, unsigned int regno0, unsigned int regno1,
- unsigned int regno2, unsigned int split_cost)
+ unsigned int regno2, int split_cost)
{
int dist_define, dist_use;
regno0 = true_regnum (operands[0]);
regno1 = true_regnum (operands[1]);
- return ix86_lea_outperforms (insn, regno0, regno1, -1, 0);
+ return ix86_lea_outperforms (insn, regno0, regno1, INVALID_REGNUM, 0);
}
/* Return true if we need to split lea into a sequence of
ix86_avoid_lea_for_addr (rtx insn, rtx operands[])
{
unsigned int regno0 = true_regnum (operands[0]) ;
- unsigned int regno1 = -1;
- unsigned int regno2 = -1;
- unsigned int split_cost = 0;
+ unsigned int regno1 = INVALID_REGNUM;
+ unsigned int regno2 = INVALID_REGNUM;
+ int split_cost = 0;
struct ix86_address parts;
int ok;
ok = ix86_decompose_address (operands[1], &parts);
gcc_assert (ok);
+ /* There should be at least two components in the address. */
+ if ((parts.base != NULL_RTX) + (parts.index != NULL_RTX)
+ + (parts.disp != NULL_RTX) + (parts.scale > 1) < 2)
+ return false;
+
/* We should not split into add if non legitimate pic
operand is used as displacement. */
if (parts.disp && flag_pic && !LEGITIMATE_PIC_OPERAND_P (parts.disp))