* [PATCH, i386]: Make ix86_lea_outperform static and cleanup LEA split helpers
@ 2012-07-23 18:08 Uros Bizjak
0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2012-07-23 18:08 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 575 bytes --]
Hello!
No functional changes.
2012-07-23 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386-protos.c (ix86_lea_outperforms): Remove prototype.
* config/i386/i386.c (ix86_lea_outperforms): Make static. Make
split_cost argument signed.
(ix86_avoid_lea_for_add): Cleanup.
(ix86_use_lea_for_mov): Use INVALID_REGNUM instead of -1.
(ix86_avoid_lea_for_addr): Ditto. Make split_cost signed.
Use gen_lowpart instead of gen_rtx_SUBREG. Cleanup.
Tested on x86_64-pc-linux-gnu {,-m32} configure with --with-arch=core2
--with-cpu=atom, committed to mainline SVN.
Uros.
[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 6887 bytes --]
Index: i386.c
===================================================================
--- i386.c (revision 189787)
+++ i386.c (working copy)
@@ -16805,9 +16805,9 @@ distance_agu_use (unsigned int regno0, rtx insn)
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;
@@ -16880,9 +16880,7 @@ ix86_ok_to_clobber_flags (rtx insn)
bool
ix86_avoid_lea_for_add (rtx insn, rtx operands[])
{
- unsigned int regno0 = true_regnum (operands[0]);
- unsigned int regno1 = true_regnum (operands[1]);
- unsigned int regno2 = true_regnum (operands[2]);
+ unsigned int regno0, regno1, regno2;
/* Check if we need to optimize. */
if (!TARGET_OPT_AGU || optimize_function_for_size_p (cfun))
@@ -16892,6 +16890,10 @@ ix86_avoid_lea_for_add (rtx insn, rtx operands[])
if (!ix86_ok_to_clobber_flags(insn))
return false;
+ regno0 = true_regnum (operands[0]);
+ regno1 = true_regnum (operands[1]);
+ regno2 = true_regnum (operands[2]);
+
/* We need to split only adds with non destructive
destination operand. */
if (regno0 == regno1 || regno0 == regno2)
@@ -16906,8 +16908,7 @@ ix86_avoid_lea_for_add (rtx insn, rtx operands[])
bool
ix86_use_lea_for_mov (rtx insn, rtx operands[])
{
- unsigned int regno0;
- unsigned int regno1;
+ unsigned int regno0, regno1;
/* Check if we need to optimize. */
if (!TARGET_OPT_AGU || optimize_function_for_size_p (cfun))
@@ -16920,7 +16921,7 @@ ix86_use_lea_for_mov (rtx insn, rtx operands[])
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
@@ -16929,10 +16930,8 @@ ix86_use_lea_for_mov (rtx insn, rtx operands[])
bool
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 regno0, regno1, regno2;
+ int split_cost;
struct ix86_address parts;
int ok;
@@ -16957,11 +16956,17 @@ ix86_avoid_lea_for_addr (rtx insn, rtx operands[])
if (parts.disp && flag_pic && !LEGITIMATE_PIC_OPERAND_P (parts.disp))
return false;
+ regno0 = true_regnum (operands[0]) ;
+ regno1 = INVALID_REGNUM;
+ regno2 = INVALID_REGNUM;
+
if (parts.base)
regno1 = true_regnum (parts.base);
if (parts.index)
regno2 = true_regnum (parts.index);
+ split_cost = 0;
+
/* Compute how many cycles we will add to execution time
if split lea into a sequence of instructions. */
if (parts.base || parts.index)
@@ -17021,27 +17026,31 @@ ix86_emit_binop (enum rtx_code code, enum machine_
extern void
ix86_split_lea_for_addr (rtx operands[], enum machine_mode mode)
{
- unsigned int regno0 = true_regnum (operands[0]) ;
- unsigned int regno1 = INVALID_REGNUM;
- unsigned int regno2 = INVALID_REGNUM;
+ unsigned int regno0, regno1, regno2;
struct ix86_address parts;
- rtx tmp;
+ rtx target, tmp;
int ok, adds;
ok = ix86_decompose_address (operands[1], &parts);
gcc_assert (ok);
+ target = operands[0];
+
+ regno0 = true_regnum (target);
+ regno1 = INVALID_REGNUM;
+ regno2 = INVALID_REGNUM;
+
if (parts.base)
{
if (GET_MODE (parts.base) != mode)
- parts.base = gen_rtx_SUBREG (mode, parts.base, 0);
+ parts.base = gen_lowpart (mode, parts.base);
regno1 = true_regnum (parts.base);
}
if (parts.index)
{
if (GET_MODE (parts.index) != mode)
- parts.index = gen_rtx_SUBREG (mode, parts.index, 0);
+ parts.index = gen_lowpart (mode, parts.index);
regno2 = true_regnum (parts.index);
}
@@ -17057,41 +17066,41 @@ ix86_split_lea_for_addr (rtx operands[], enum mach
gcc_assert (regno2 != regno0);
for (adds = parts.scale; adds > 0; adds--)
- ix86_emit_binop (PLUS, mode, operands[0], parts.index);
+ ix86_emit_binop (PLUS, mode, target, parts.index);
}
else
{
/* r1 = r2 + r3 * C case. Need to move r3 into r1. */
if (regno0 != regno2)
- emit_insn (gen_rtx_SET (VOIDmode, operands[0], parts.index));
+ emit_insn (gen_rtx_SET (VOIDmode, target, parts.index));
/* Use shift for scaling. */
- ix86_emit_binop (ASHIFT, mode, operands[0],
+ ix86_emit_binop (ASHIFT, mode, target,
GEN_INT (exact_log2 (parts.scale)));
if (parts.base)
- ix86_emit_binop (PLUS, mode, operands[0], parts.base);
+ ix86_emit_binop (PLUS, mode, target, parts.base);
if (parts.disp && parts.disp != const0_rtx)
- ix86_emit_binop (PLUS, mode, operands[0], parts.disp);
+ ix86_emit_binop (PLUS, mode, target, parts.disp);
}
}
else if (!parts.base && !parts.index)
{
gcc_assert(parts.disp);
- emit_insn (gen_rtx_SET (VOIDmode, operands[0], parts.disp));
+ emit_insn (gen_rtx_SET (VOIDmode, target, parts.disp));
}
else
{
if (!parts.base)
{
if (regno0 != regno2)
- emit_insn (gen_rtx_SET (VOIDmode, operands[0], parts.index));
+ emit_insn (gen_rtx_SET (VOIDmode, target, parts.index));
}
else if (!parts.index)
{
if (regno0 != regno1)
- emit_insn (gen_rtx_SET (VOIDmode, operands[0], parts.base));
+ emit_insn (gen_rtx_SET (VOIDmode, target, parts.base));
}
else
{
@@ -17101,15 +17110,15 @@ ix86_split_lea_for_addr (rtx operands[], enum mach
tmp = parts.base;
else
{
- emit_insn (gen_rtx_SET (VOIDmode, operands[0], parts.base));
+ emit_insn (gen_rtx_SET (VOIDmode, target, parts.base));
tmp = parts.index;
}
- ix86_emit_binop (PLUS, mode, operands[0], tmp);
+ ix86_emit_binop (PLUS, mode, target, tmp);
}
if (parts.disp && parts.disp != const0_rtx)
- ix86_emit_binop (PLUS, mode, operands[0], parts.disp);
+ ix86_emit_binop (PLUS, mode, target, parts.disp);
}
}
Index: i386-protos.h
===================================================================
--- i386-protos.h (revision 189786)
+++ i386-protos.h (working copy)
@@ -92,8 +92,6 @@ extern void ix86_fixup_binary_operands_no_copy (en
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[]);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-07-23 18:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-23 18:08 [PATCH, i386]: Make ix86_lea_outperform static and cleanup LEA split helpers Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).