Skip to content

Commit ec5a350

Browse files
rsandifoRichard Sandiford
authored andcommitted
rtlanal.c (must_be_base_p, [...]): Delete.
gcc/ * rtlanal.c (must_be_base_p, must_be_index_p): Delete. (binary_scale_code_p, get_base_term, get_index_term): New functions. (set_address_segment, set_address_base, set_address_index) (set_address_disp): Accept the argument unconditionally. (baseness): Remove must_be_base_p and must_be_index_p checks. (decompose_normal_address): Classify as much as possible in the main loop. From-SVN: r202970
1 parent f91aec9 commit ec5a350

File tree

2 files changed

+68
-43
lines changed

2 files changed

+68
-43
lines changed

gcc/ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2013-09-27 Richard Sandiford <[email protected]>
2+
3+
* rtlanal.c (must_be_base_p, must_be_index_p): Delete.
4+
(binary_scale_code_p, get_base_term, get_index_term): New functions.
5+
(set_address_segment, set_address_base, set_address_index)
6+
(set_address_disp): Accept the argument unconditionally.
7+
(baseness): Remove must_be_base_p and must_be_index_p checks.
8+
(decompose_normal_address): Classify as much as possible in the
9+
main loop.
10+
111
2013-09-27 Richard Sandiford <[email protected]>
212

313
* cse.c (count_reg_usage): Handle INT_LIST.

gcc/rtlanal.c

Lines changed: 58 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5521,26 +5521,50 @@ strip_address_mutations (rtx *loc, enum rtx_code *outer_code)
55215521
}
55225522
}
55235523

5524-
/* Return true if X must be a base rather than an index. */
5524+
/* Return true if CODE applies some kind of scale. The scaled value is
5525+
is the first operand and the scale is the second. */
55255526

55265527
static bool
5527-
must_be_base_p (rtx x)
5528+
binary_scale_code_p (enum rtx_code code)
55285529
{
5529-
return GET_CODE (x) == LO_SUM;
5530+
return (code == MULT
5531+
|| code == ASHIFT
5532+
/* Needed by ARM targets. */
5533+
|| code == ASHIFTRT
5534+
|| code == LSHIFTRT
5535+
|| code == ROTATE
5536+
|| code == ROTATERT);
55305537
}
55315538

5532-
/* Return true if X must be an index rather than a base. */
5539+
/* If *INNER can be interpreted as a base, return a pointer to the inner term
5540+
(see address_info). Return null otherwise. */
55335541

5534-
static bool
5535-
must_be_index_p (rtx x)
5542+
static rtx *
5543+
get_base_term (rtx *inner)
55365544
{
5537-
return (GET_CODE (x) == MULT
5538-
|| GET_CODE (x) == ASHIFT
5539-
/* Needed by ARM targets. */
5540-
|| GET_CODE (x) == ASHIFTRT
5541-
|| GET_CODE (x) == LSHIFTRT
5542-
|| GET_CODE (x) == ROTATE
5543-
|| GET_CODE (x) == ROTATERT);
5545+
if (GET_CODE (*inner) == LO_SUM)
5546+
inner = strip_address_mutations (&XEXP (*inner, 0));
5547+
if (REG_P (*inner)
5548+
|| MEM_P (*inner)
5549+
|| GET_CODE (*inner) == SUBREG)
5550+
return inner;
5551+
return 0;
5552+
}
5553+
5554+
/* If *INNER can be interpreted as an index, return a pointer to the inner term
5555+
(see address_info). Return null otherwise. */
5556+
5557+
static rtx *
5558+
get_index_term (rtx *inner)
5559+
{
5560+
/* At present, only constant scales are allowed. */
5561+
if (binary_scale_code_p (GET_CODE (*inner)) && CONSTANT_P (XEXP (*inner, 1)))
5562+
inner = strip_address_mutations (&XEXP (*inner, 0));
5563+
if (REG_P (*inner)
5564+
|| MEM_P (*inner)
5565+
|| GET_CODE (*inner) == SUBREG)
5566+
return inner;
5567+
return 0;
55445568
}
55455569

55465570
/* Set the segment part of address INFO to LOC, given that INNER is the
@@ -5549,8 +5573,6 @@ must_be_index_p (rtx x)
55495573
static void
55505574
set_address_segment (struct address_info *info, rtx *loc, rtx *inner)
55515575
{
5552-
gcc_checking_assert (GET_CODE (*inner) == UNSPEC);
5553-
55545576
gcc_assert (!info->segment);
55555577
info->segment = loc;
55565578
info->segment_term = inner;
@@ -5562,12 +5584,6 @@ set_address_segment (struct address_info *info, rtx *loc, rtx *inner)
55625584
static void
55635585
set_address_base (struct address_info *info, rtx *loc, rtx *inner)
55645586
{
5565-
if (must_be_base_p (*inner))
5566-
inner = strip_address_mutations (&XEXP (*inner, 0));
5567-
gcc_checking_assert (REG_P (*inner)
5568-
|| MEM_P (*inner)
5569-
|| GET_CODE (*inner) == SUBREG);
5570-
55715587
gcc_assert (!info->base);
55725588
info->base = loc;
55735589
info->base_term = inner;
@@ -5579,12 +5595,6 @@ set_address_base (struct address_info *info, rtx *loc, rtx *inner)
55795595
static void
55805596
set_address_index (struct address_info *info, rtx *loc, rtx *inner)
55815597
{
5582-
if (must_be_index_p (*inner) && CONSTANT_P (XEXP (*inner, 1)))
5583-
inner = strip_address_mutations (&XEXP (*inner, 0));
5584-
gcc_checking_assert (REG_P (*inner)
5585-
|| MEM_P (*inner)
5586-
|| GET_CODE (*inner) == SUBREG);
5587-
55885598
gcc_assert (!info->index);
55895599
info->index = loc;
55905600
info->index_term = inner;
@@ -5596,8 +5606,6 @@ set_address_index (struct address_info *info, rtx *loc, rtx *inner)
55965606
static void
55975607
set_address_disp (struct address_info *info, rtx *loc, rtx *inner)
55985608
{
5599-
gcc_checking_assert (CONSTANT_P (*inner));
5600-
56015609
gcc_assert (!info->disp);
56025610
info->disp = loc;
56035611
info->disp_term = inner;
@@ -5677,12 +5685,6 @@ static int
56775685
baseness (rtx x, enum machine_mode mode, addr_space_t as,
56785686
enum rtx_code outer_code, enum rtx_code index_code)
56795687
{
5680-
/* See whether we can be certain. */
5681-
if (must_be_base_p (x))
5682-
return 3;
5683-
if (must_be_index_p (x))
5684-
return -3;
5685-
56865688
/* Believe *_POINTER unless the address shape requires otherwise. */
56875689
if (REG_P (x) && REG_POINTER (x))
56885690
return 2;
@@ -5717,8 +5719,8 @@ decompose_normal_address (struct address_info *info)
57175719
if (n_ops > 1)
57185720
info->base_outer_code = PLUS;
57195721

5720-
/* Separate the parts that contain a REG or MEM from those that don't.
5721-
Record the latter in INFO and leave the former in OPS. */
5722+
/* Try to classify each sum operand now. Leave those that could be
5723+
either a base or an index in OPS. */
57225724
rtx *inner_ops[4];
57235725
size_t out = 0;
57245726
for (size_t in = 0; in < n_ops; ++in)
@@ -5731,18 +5733,31 @@ decompose_normal_address (struct address_info *info)
57315733
set_address_segment (info, loc, inner);
57325734
else
57335735
{
5734-
ops[out] = loc;
5735-
inner_ops[out] = inner;
5736-
++out;
5736+
/* The only other possibilities are a base or an index. */
5737+
rtx *base_term = get_base_term (inner);
5738+
rtx *index_term = get_index_term (inner);
5739+
gcc_assert (base_term || index_term);
5740+
if (!base_term)
5741+
set_address_index (info, loc, index_term);
5742+
else if (!index_term)
5743+
set_address_base (info, loc, base_term);
5744+
else
5745+
{
5746+
gcc_assert (base_term == index_term);
5747+
ops[out] = loc;
5748+
inner_ops[out] = base_term;
5749+
++out;
5750+
}
57375751
}
57385752
}
57395753

57405754
/* Classify the remaining OPS members as bases and indexes. */
57415755
if (out == 1)
57425756
{
5743-
/* Assume that the remaining value is a base unless the shape
5744-
requires otherwise. */
5745-
if (!must_be_index_p (*inner_ops[0]))
5757+
/* If we haven't seen a base or an index yet, assume that this is
5758+
the base. If we were confident that another term was the base
5759+
or index, treat the remaining operand as the other kind. */
5760+
if (!info->base)
57465761
set_address_base (info, ops[0], inner_ops[0]);
57475762
else
57485763
set_address_index (info, ops[0], inner_ops[0]);

0 commit comments

Comments
 (0)