{ if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG \
&& GET_CODE (XEXP (X, 1)) == CONST_INT \
&& (unsigned) (INTVAL (XEXP (X, 1)) + 0x8000) >= 0x10000) \
- { int high_int, low_int; \
- high_int = INTVAL (XEXP (X, 1)) >> 16; \
+ { HOST_WIDE_INT high_int, low_int; \
+ rtx sum; \
+ high_int = INTVAL (XEXP (X, 1)) & (~ (HOST_WIDE_INT) 0xffff); \
low_int = INTVAL (XEXP (X, 1)) & 0xffff; \
if (low_int & 0x8000) \
- high_int += 1, low_int |= 0xffff0000; \
- (X) = gen_rtx (PLUS, Pmode, \
- force_operand \
- (gen_rtx (PLUS, Pmode, XEXP (X, 0), \
- gen_rtx (CONST_INT, VOIDmode, \
- high_int << 16)), 0), \
- gen_rtx (CONST_INT, VOIDmode, low_int)); \
+ high_int += 0x10000, low_int |= ((HOST_WIDE_INT) -1) << 16; \
+ sum = force_operand (gen_rtx (PLUS, Pmode, XEXP (X, 0), \
+ GEN_INT (high_int)), 0); \
+ (X) = gen_rtx (PLUS, Pmode, sum, GEN_INT (low_int)); \
goto WIN; \
} \
else if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG \
(no need to use the default) */
#define MACHINE_issue_rate
+/* General optimization flags. */
+extern int optimize;
+extern int flag_expensive_optimizations;
+
/* Declare functions in rs6000.c */
extern void output_options ();
extern void rs6000_override_options ();
if (sym && GET_CODE (const_term) == CONST_INT
&& (GET_CODE (sym) == SYMBOL_REF || GET_CODE (sym) == LABEL_REF))
{
- emit_insn (gen_movsi (operands[0], sym));
+ unsigned HOST_WIDE_INT value = INTVAL (const_term);
+ int new_reg_p = (flag_expensive_optimizations
+ && !reload_completed
+ && !reload_in_progress);
+ rtx tmp1 = (new_reg_p && value != 0) ? gen_reg_rtx (SImode) : operands[0];
+
+ emit_insn (gen_movsi (tmp1, sym));
if (INTVAL (const_term) != 0)
{
- unsigned HOST_WIDE_INT value = INTVAL (const_term);
if (value + 0x8000 < 0x10000)
- emit_insn (gen_addsi3 (operands[0], operands[0], GEN_INT (value)));
+ emit_insn (gen_addsi3 (operands[0], tmp1, GEN_INT (value)));
+
else
{
- emit_insn (gen_addsi3 (operands[0], operands[0],
- GEN_INT ((value >> 16) + ((value >> 15) & 1))));
+ HOST_WIDE_INT high_int = value & (~ (HOST_WIDE_INT) 0xffff);
+ HOST_WIDE_INT low_int = value & 0xffff;
+ rtx tmp2 = (!new_reg_p || !low_int) ? operands[0] : gen_reg_rtx (Pmode);
+
+ if (low_int & 0x8000)
+ high_int += 0x10000, low_int |= ((HOST_WIDE_INT) -1) << 16;
- if ((value & 0xffff) != 0)
- emit_insn (gen_addsi3 (operands[0], operands[0],
- GEN_INT (value & 0xffff)));
+ emit_insn (gen_addsi3 (tmp2, tmp1, GEN_INT (high_int)));
+ if (low_int)
+ emit_insn (gen_addsi3 (operands[0], tmp2, GEN_INT (low_int)));
}
}
DONE;