This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch] Add and use new RTL predicates
On 06/12/2009 05:16 PM, Paolo Bonzini wrote:
Yes, that's what I disagree with. :-)
Actually to be a bit less pedantic, I'd say I agree with predicates
for every RTL expression in class RTX_OBJECT (REG, MEM, SUBREG,
SYMBOL_REF and a few others). I would even love to have SUBREG_REG_P for
GET_CODE (X) == SUBREG && GET_CODE (SUBREG_REG (X)) == REG
Add SUBREG_REG_P predicate as Paolo Bonzini's suggestion.
A predicate named REG_SUBREG_P defined at ira-conflicts.c
#define
REG_SUBREG_P(x) \
(REG_P (x) || (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x))))
This expression is also used at many other places. I moved it to rtl.h.
Tested on i686-pc-linux-gnu.
btw, ping the patch that used the existing REG_P, MEM_P ... predicates
http://gcc.gnu.org/ml/gcc-patches/2009-05/msg01369.html
In the end it was SET_P and PLUS_P that I didn't like (though I know
they're quite frequent), and PARALLEL_P that I didn't feel the need for.
Paolo
2009-06-16 Shujing Zhao <pearly.zhao@oracle.com>
* ira-conflicts.c (REG_SUBREG_P): Move ...
* rtl.h: ... to here.
(SUBREG_REG_P): New predicate.
* caller-save.c: Use REG_SUBREG_P and SUBREG_REG_P where applicable.
* calls.c: Ditto.
* combine.c: Ditto.
* cse.c: Ditto.
* function.c: Ditto.
* fwprop.c: Ditto.
* ifcvt.c: Ditto.
* jump.c: Ditto.
* loop-unroll.c: Ditto.
* mode-switching.c: Ditto.
* reg-stack.c: Ditto.
* reload1.c: Ditto.
* reload.c: Ditto.
* resource.c: Ditto.
* rtlanal.c: Ditto.
* see.c: Ditto.
* simplify-rtx.c: Ditto.
Index: caller-save.c
===================================================================
--- caller-save.c (revision 148516)
+++ caller-save.c (working copy)
@@ -921,8 +921,7 @@ add_stored_regs (rtx reg, const_rtx sett
if (GET_CODE (setter) == CLOBBER)
return;
- if (GET_CODE (reg) == SUBREG
- && REG_P (SUBREG_REG (reg))
+ if (SUBREG_REG_P (reg)
&& REGNO (SUBREG_REG (reg)) < FIRST_PSEUDO_REGISTER)
{
offset = subreg_regno_offset (REGNO (SUBREG_REG (reg)),
@@ -961,7 +960,7 @@ mark_referenced_regs (rtx x)
code = GET_CODE (x);
if ((code == REG && REGNO (x) < FIRST_PSEUDO_REGISTER)
|| code == PC || code == CC0
- || (code == SUBREG && REG_P (SUBREG_REG (x))
+ || (SUBREG_REG_P (x)
&& REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER
/* If we're setting only part of a multi-word register,
we shall mark it as referenced, because the words
Index: calls.c
===================================================================
--- calls.c (revision 148516)
+++ calls.c (working copy)
@@ -713,9 +713,7 @@ precompute_register_parameters (int num_
register parameters. This is to avoid reload conflicts while
loading the parameters registers. */
- else if ((! (REG_P (args[i].value)
- || (GET_CODE (args[i].value) == SUBREG
- && REG_P (SUBREG_REG (args[i].value)))))
+ else if (!REG_SUBREG_P (args[i].value)
&& args[i].mode != BLKmode
&& rtx_cost (args[i].value, SET, optimize_insn_for_speed_p ())
> COSTS_N_INSNS (1)
Index: combine.c
===================================================================
--- combine.c (revision 148516)
+++ combine.c (working copy)
@@ -525,8 +525,7 @@ find_single_use_1 (rtx dest, rtx *loc)
if (GET_CODE (SET_DEST (x)) != CC0
&& GET_CODE (SET_DEST (x)) != PC
&& !REG_P (SET_DEST (x))
- && ! (GET_CODE (SET_DEST (x)) == SUBREG
- && REG_P (SUBREG_REG (SET_DEST (x)))
+ && ! (SUBREG_REG_P (SET_DEST (x))
&& (((GET_MODE_SIZE (GET_MODE (SUBREG_REG (SET_DEST (x))))
+ (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
== ((GET_MODE_SIZE (GET_MODE (SET_DEST (x)))
@@ -4861,9 +4860,7 @@ combine_simplify_rtx (rtx x, enum machin
or a SUBREG of one since we'd be making the expression more
complex if it was just a register. */
- if (!REG_P (temp)
- && ! (GET_CODE (temp) == SUBREG
- && REG_P (SUBREG_REG (temp)))
+ if (!REG_SUBREG_P (temp)
&& (i = exact_log2 (nonzero_bits (temp, mode))) >= 0)
{
rtx temp1 = simplify_shift_const
@@ -4957,9 +4954,7 @@ combine_simplify_rtx (rtx x, enum machin
the bitsize of the mode - 1. This allows simplification of
"a = (b & 8) == 0;" */
if (XEXP (x, 1) == constm1_rtx
- && !REG_P (XEXP (x, 0))
- && ! (GET_CODE (XEXP (x, 0)) == SUBREG
- && REG_P (SUBREG_REG (XEXP (x, 0))))
+ && !REG_SUBREG_P (XEXP (x, 0))
&& nonzero_bits (XEXP (x, 0), mode) == 1)
return simplify_shift_const (NULL_RTX, ASHIFTRT, mode,
simplify_shift_const (NULL_RTX, ASHIFT, mode,
@@ -5795,9 +5790,7 @@ simplify_set (rtx x)
GET_MODE (SUBREG_REG (src)),
GET_MODE (src)))
#endif
- && (REG_P (dest)
- || (GET_CODE (dest) == SUBREG
- && REG_P (SUBREG_REG (dest)))))
+ && REG_SUBREG_P (dest))
{
SUBST (SET_DEST (x),
gen_lowpart (GET_MODE (SUBREG_REG (src)),
@@ -11617,7 +11610,7 @@ record_truncated_value (rtx *p, void *da
enum machine_mode truncated_mode;
reg_stat_type *rsp;
- if (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x)))
+ if (SUBREG_REG_P (x))
{
enum machine_mode original_mode = GET_MODE (SUBREG_REG (x));
truncated_mode = GET_MODE (x);
@@ -11667,9 +11660,8 @@ record_truncated_values (rtx *x, void *d
static void
check_promoted_subreg (rtx insn, rtx x)
{
- if (GET_CODE (x) == SUBREG
- && SUBREG_PROMOTED_VAR_P (x)
- && REG_P (SUBREG_REG (x)))
+ if (SUBREG_REG_P (x)
+ && SUBREG_PROMOTED_VAR_P (x))
record_promoted_value (insn, x);
else
{
Index: cse.c
===================================================================
--- cse.c (revision 148516)
+++ cse.c (working copy)
@@ -755,8 +755,7 @@ preferable (int cost_a, int regcost_a, i
static int
notreg_cost (rtx x, enum rtx_code outer)
{
- return ((GET_CODE (x) == SUBREG
- && REG_P (SUBREG_REG (x))
+ return ((SUBREG_REG_P (x)
&& GET_MODE_CLASS (GET_MODE (x)) == MODE_INT
&& GET_MODE_CLASS (GET_MODE (SUBREG_REG (x))) == MODE_INT
&& (GET_MODE_SIZE (GET_MODE (x))
@@ -1059,7 +1058,7 @@ mention_regs (rtx x)
/* If this is a SUBREG, we don't want to discard other SUBREGs of the same
pseudo if they don't use overlapping words. We handle only pseudos
here for simplicity. */
- if (code == SUBREG && REG_P (SUBREG_REG (x))
+ if (SUBREG_REG_P (x)
&& REGNO (SUBREG_REG (x)) >= FIRST_PSEUDO_REGISTER)
{
unsigned int i = REGNO (SUBREG_REG (x));
@@ -1209,7 +1208,7 @@ insert_regs (rtx x, struct table_elt *cl
not be accessible because its hash code will have changed. So assign
a quantity number now. */
- else if (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x))
+ else if (SUBREG_REG_P (x)
&& ! REGNO_QTY_VALID_P (REGNO (SUBREG_REG (x))))
{
insert_regs (SUBREG_REG (x), NULL, 0);
@@ -2031,8 +2030,7 @@ remove_invalid_subreg_refs (unsigned int
next = p->next_same_hash;
if (!REG_P (exp)
- && (GET_CODE (exp) != SUBREG
- || !REG_P (SUBREG_REG (exp))
+ && (!SUBREG_REG_P (exp)
|| REGNO (SUBREG_REG (exp)) != regno
|| (((SUBREG_BYTE (exp)
+ (GET_MODE_SIZE (GET_MODE (exp)) - 1)) >= offset)
Index: function.c
===================================================================
--- function.c (revision 148516)
+++ function.c (working copy)
@@ -2829,9 +2829,8 @@ assign_parm_setup_reg (struct assign_par
push_to_sequence2 (all->first_conversion_insn, all->last_conversion_insn);
tempreg = convert_to_mode (data->nominal_mode, tempreg, unsignedp);
- if (GET_CODE (tempreg) == SUBREG
+ if (SUBREG_REG_P (tempreg)
&& GET_MODE (tempreg) == data->nominal_mode
- && REG_P (SUBREG_REG (tempreg))
&& data->nominal_mode == data->passed_mode
&& GET_MODE (SUBREG_REG (tempreg)) == GET_MODE (data->entry_parm)
&& GET_MODE_SIZE (GET_MODE (tempreg))
Index: fwprop.c
===================================================================
--- fwprop.c (revision 148516)
+++ fwprop.c (working copy)
@@ -771,9 +771,7 @@ find_occurrence (rtx *px, rtx find)
{
struct find_occurrence_data data;
- gcc_assert (REG_P (find)
- || (GET_CODE (find) == SUBREG
- && REG_P (SUBREG_REG (find))));
+ gcc_assert (REG_SUBREG_P (find));
data.find = find;
data.retval = NULL;
@@ -947,8 +945,7 @@ forward_propagate_subreg (df_ref use, rt
these SUBREGs just say how to treat the register. */
use_insn = DF_REF_INSN (use);
src = SET_SRC (def_set);
- if (GET_CODE (src) == SUBREG
- && REG_P (SUBREG_REG (src))
+ if (SUBREG_REG_P (src)
&& GET_MODE (SUBREG_REG (src)) == use_mode
&& subreg_lowpart_p (src)
&& all_uses_available_at (def_insn, use_insn))
Index: ifcvt.c
===================================================================
--- ifcvt.c (revision 148516)
+++ ifcvt.c (working copy)
@@ -2506,7 +2506,7 @@ check_cond_move_block (basic_block bb, r
modified earlier in the block. */
if ((REG_P (src)
&& vals[REGNO (src)] != NULL)
- || (GET_CODE (src) == SUBREG && REG_P (SUBREG_REG (src))
+ || (SUBREG_REG_P (src)
&& vals[REGNO (SUBREG_REG (src))] != NULL))
return FALSE;
Index: ira-conflicts.c
===================================================================
--- ira-conflicts.c (revision 148516)
+++ ira-conflicts.c (working copy)
@@ -317,10 +317,6 @@ get_dup (int op_num, bool use_commut_op_
return recog_data.operand[n];
}
-/* Check that X is REG or SUBREG of REG. */
-#define REG_SUBREG_P(x) \
- (REG_P (x) || (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x))))
-
/* Return X if X is a REG, otherwise it should be SUBREG of REG and
the function returns the reg in this case. *OFFSET will be set to
0 in the first case or the regno offset in the first case. */
Index: jump.c
===================================================================
--- jump.c (revision 148516)
+++ jump.c (working copy)
@@ -1566,9 +1566,7 @@ rtx_renumbered_equal_p (const_rtx x, con
if (x == y)
return 1;
- if ((code == REG || (code == SUBREG && REG_P (SUBREG_REG (x))))
- && (REG_P (y) || (GET_CODE (y) == SUBREG
- && REG_P (SUBREG_REG (y)))))
+ if (REG_SUBREG_P (x) && REG_SUBREG_P (y))
{
int reg_x = -1, reg_y = -1;
int byte_x = 0, byte_y = 0;
Index: loop-unroll.c
===================================================================
--- loop-unroll.c (revision 148516)
+++ loop-unroll.c (working copy)
@@ -1607,9 +1607,7 @@ analyze_insn_to_expand_var (struct loop
op1 = XEXP (src, 0);
op2 = XEXP (src, 1);
- if (!REG_P (dest)
- && !(GET_CODE (dest) == SUBREG
- && REG_P (SUBREG_REG (dest))))
+ if (!REG_SUBREG_P (dest))
return NULL;
if (rtx_equal_p (dest, op1))
Index: mode-switching.c
===================================================================
--- mode-switching.c (revision 148516)
+++ mode-switching.c (working copy)
@@ -319,8 +319,7 @@ create_pre_exit (int n_entities, int *en
copy_reg = SET_DEST (return_copy_pat);
if (GET_CODE (copy_reg) == REG)
copy_start = REGNO (copy_reg);
- else if (GET_CODE (copy_reg) == SUBREG
- && GET_CODE (SUBREG_REG (copy_reg)) == REG)
+ else if (SUBREG_REG_P (copy_reg))
copy_start = REGNO (SUBREG_REG (copy_reg));
else
break;
Index: reg-stack.c
===================================================================
--- reg-stack.c (revision 148516)
+++ reg-stack.c (working copy)
@@ -493,8 +493,7 @@ check_asm_stack_operands (rtx insn)
/* Strip SUBREGs here to make the following code simpler. */
for (i = 0; i < recog_data.n_operands; i++)
- if (GET_CODE (recog_data.operand[i]) == SUBREG
- && REG_P (SUBREG_REG (recog_data.operand[i])))
+ if (SUBREG_REG_P (recog_data.operand[i]))
recog_data.operand[i] = SUBREG_REG (recog_data.operand[i]);
/* Set up CLOBBER_REG. */
@@ -511,7 +510,7 @@ check_asm_stack_operands (rtx insn)
rtx clobber = XVECEXP (body, 0, i);
rtx reg = XEXP (clobber, 0);
- if (GET_CODE (reg) == SUBREG && REG_P (SUBREG_REG (reg)))
+ if (SUBREG_REG_P (reg))
reg = SUBREG_REG (reg);
if (STACK_REG_P (reg))
@@ -2014,8 +2013,7 @@ subst_asm_stack_regs (rtx insn, stack re
/* Strip SUBREGs here to make the following code simpler. */
for (i = 0; i < recog_data.n_operands; i++)
- if (GET_CODE (recog_data.operand[i]) == SUBREG
- && REG_P (SUBREG_REG (recog_data.operand[i])))
+ if (SUBREG_REG_P (recog_data.operand[i]))
{
recog_data.operand_loc[i] = & SUBREG_REG (recog_data.operand[i]);
recog_data.operand[i] = SUBREG_REG (recog_data.operand[i]);
@@ -2036,7 +2034,7 @@ subst_asm_stack_regs (rtx insn, stack re
rtx reg = XEXP (note, 0);
rtx *loc = & XEXP (note, 0);
- if (GET_CODE (reg) == SUBREG && REG_P (SUBREG_REG (reg)))
+ if (SUBREG_REG_P (reg))
{
loc = & SUBREG_REG (reg);
reg = SUBREG_REG (reg);
@@ -2069,7 +2067,7 @@ subst_asm_stack_regs (rtx insn, stack re
rtx reg = XEXP (clobber, 0);
rtx *loc = & XEXP (clobber, 0);
- if (GET_CODE (reg) == SUBREG && REG_P (SUBREG_REG (reg)))
+ if (SUBREG_REG_P (reg))
{
loc = & SUBREG_REG (reg);
reg = SUBREG_REG (reg);
Index: reload1.c
===================================================================
--- reload1.c (revision 148516)
+++ reload1.c (working copy)
@@ -6011,8 +6011,7 @@ choose_reload_regs (struct insn_chain *c
regno = REGNO (rld[r].in_reg);
mode = GET_MODE (rld[r].in_reg);
}
- else if (GET_CODE (rld[r].in_reg) == SUBREG
- && REG_P (SUBREG_REG (rld[r].in_reg)))
+ else if (SUBREG_REG_P (rld[r].in_reg))
{
regno = REGNO (SUBREG_REG (rld[r].in_reg));
if (regno < FIRST_PSEUDO_REGISTER)
@@ -7225,8 +7224,7 @@ emit_input_reload_insns (struct insn_cha
&& REGNO (oldequiv) >= FIRST_PSEUDO_REGISTER
&& (reg_equiv_memory_loc[REGNO (oldequiv)] != 0
|| reg_equiv_constant[REGNO (oldequiv)] != 0))
- || (GET_CODE (oldequiv) == SUBREG
- && REG_P (SUBREG_REG (oldequiv))
+ || (SUBREG_REG_P (oldequiv)
&& (REGNO (SUBREG_REG (oldequiv))
>= FIRST_PSEUDO_REGISTER)
&& ((reg_equiv_memory_loc
@@ -7641,8 +7639,7 @@ do_output_reload (struct insn_chain *cha
return;
}
/* Likewise for a SUBREG of an operand that dies. */
- else if (GET_CODE (old) == SUBREG
- && REG_P (SUBREG_REG (old))
+ else if (SUBREG_REG_P (old)
&& 0 != (note = find_reg_note (insn, REG_UNUSED,
SUBREG_REG (old))))
{
@@ -8288,11 +8285,9 @@ gen_reload (rtx out, rtx in, int opnum,
#ifdef SECONDARY_MEMORY_NEEDED
/* If we need a memory location to do the move, do it that way. */
- else if ((REG_P (in)
- || (GET_CODE (in) == SUBREG && REG_P (SUBREG_REG (in))))
+ else if (REG_SUBREG_P (in)
&& reg_or_subregno (in) < FIRST_PSEUDO_REGISTER
- && (REG_P (out)
- || (GET_CODE (out) == SUBREG && REG_P (SUBREG_REG (out))))
+ && REG_SUBREG_P (out)
&& reg_or_subregno (out) < FIRST_PSEUDO_REGISTER
&& SECONDARY_MEMORY_NEEDED (REGNO_REG_CLASS (reg_or_subregno (in)),
REGNO_REG_CLASS (reg_or_subregno (out)),
Index: reload.c
===================================================================
--- reload.c (revision 148516)
+++ reload.c (working copy)
@@ -1197,14 +1197,13 @@ push_reload (rtx in, rtx out, rtx *inloc
/* If IN is a SUBREG of a hard register, make a new REG. This
simplifies some of the cases below. */
- if (in != 0 && GET_CODE (in) == SUBREG && REG_P (SUBREG_REG (in))
+ if (in != 0 && SUBREG_REG_P (in)
&& REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER
&& ! dont_remove_subreg)
in = gen_rtx_REG (GET_MODE (in), subreg_regno (in));
/* Similarly for OUT. */
- if (out != 0 && GET_CODE (out) == SUBREG
- && REG_P (SUBREG_REG (out))
+ if (out != 0 && SUBREG_REG_P (out)
&& REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER
&& ! dont_remove_subreg)
out = gen_rtx_REG (GET_MODE (out), subreg_regno (out));
@@ -1317,8 +1316,7 @@ push_reload (rtx in, rtx out, rtx *inloc
#ifdef SECONDARY_MEMORY_NEEDED
/* If a memory location is needed for the copy, make one. */
if (in != 0
- && (REG_P (in)
- || (GET_CODE (in) == SUBREG && REG_P (SUBREG_REG (in))))
+ && REG_SUBREG_P (in)
&& reg_or_subregno (in) < FIRST_PSEUDO_REGISTER
&& SECONDARY_MEMORY_NEEDED (REGNO_REG_CLASS (reg_or_subregno (in)),
rclass, inmode))
@@ -1349,8 +1347,7 @@ push_reload (rtx in, rtx out, rtx *inloc
#ifdef SECONDARY_MEMORY_NEEDED
if (out != 0
- && (REG_P (out)
- || (GET_CODE (out) == SUBREG && REG_P (SUBREG_REG (out))))
+ && REG_SUBREG_P (out)
&& reg_or_subregno (out) < FIRST_PSEUDO_REGISTER
&& SECONDARY_MEMORY_NEEDED (rclass,
REGNO_REG_CLASS (reg_or_subregno (out)),
@@ -2171,9 +2168,7 @@ operands_match_p (rtx x, rtx y)
if (x == y)
return 1;
- if ((code == REG || (code == SUBREG && REG_P (SUBREG_REG (x))))
- && (REG_P (y) || (GET_CODE (y) == SUBREG
- && REG_P (SUBREG_REG (y)))))
+ if (REG_SUBREG_P (x) && REG_SUBREG_P (y))
{
int j;
@@ -4676,7 +4671,7 @@ find_reloads_toplev (rtx x, int opnum, e
return tem;
}
- if (code == SUBREG && REG_P (SUBREG_REG (x)))
+ if (SUBREG_REG_P (x))
{
/* Check for SUBREG containing a REG that's equivalent to a
constant. If the constant has a known value, truncate it
@@ -6471,9 +6466,8 @@ refers_to_regno_for_reload_p (unsigned i
/* Note setting a SUBREG counts as referring to the REG it is in for
a pseudo but not for hard registers since we can
treat each word individually. */
- && ((GET_CODE (SET_DEST (x)) == SUBREG
+ && ((SUBREG_REG_P (SET_DEST (x))
&& loc != &SUBREG_REG (SET_DEST (x))
- && REG_P (SUBREG_REG (SET_DEST (x)))
&& REGNO (SUBREG_REG (SET_DEST (x))) >= FIRST_PSEUDO_REGISTER
&& refers_to_regno_for_reload_p (regno, endregno,
SUBREG_REG (SET_DEST (x)),
Index: resource.c
===================================================================
--- resource.c (revision 148516)
+++ resource.c (working copy)
@@ -94,8 +94,7 @@ update_live_status (rtx dest, const_rtx
int first_regno, last_regno;
int i;
- if (!REG_P (dest)
- && (GET_CODE (dest) != SUBREG || !REG_P (SUBREG_REG (dest))))
+ if (!REG_SUBREG_P(dest))
return;
if (GET_CODE (dest) == SUBREG)
Index: rtlanal.c
===================================================================
--- rtlanal.c (revision 148516)
+++ rtlanal.c (working copy)
@@ -769,8 +769,7 @@ reg_referenced_p (const_rtx x, const_rtx
if (GET_CODE (SET_DEST (body)) != CC0
&& GET_CODE (SET_DEST (body)) != PC
&& !REG_P (SET_DEST (body))
- && ! (GET_CODE (SET_DEST (body)) == SUBREG
- && REG_P (SUBREG_REG (SET_DEST (body)))
+ && ! (SUBREG_REG_P (SET_DEST (body))
&& (((GET_MODE_SIZE (GET_MODE (SUBREG_REG (SET_DEST (body))))
+ (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
== ((GET_MODE_SIZE (GET_MODE (SET_DEST (body)))
@@ -1281,9 +1280,8 @@ refers_to_regno_p (unsigned int regno, u
/* Note setting a SUBREG counts as referring to the REG it is in for
a pseudo but not for hard registers since we can
treat each word individually. */
- && ((GET_CODE (SET_DEST (x)) == SUBREG
+ && ((SUBREG_REG_P (SET_DEST (x))
&& loc != &SUBREG_REG (SET_DEST (x))
- && REG_P (SUBREG_REG (SET_DEST (x)))
&& REGNO (SUBREG_REG (SET_DEST (x))) >= FIRST_PSEUDO_REGISTER
&& refers_to_regno_p (regno, endregno,
SUBREG_REG (SET_DEST (x)), loc))
Index: rtl.h
===================================================================
--- rtl.h (revision 148516)
+++ rtl.h (working copy)
@@ -395,6 +395,14 @@ struct GTY(()) rtvec_def {
/* Predicate yielding nonzero iff X is a barrier insn. */
#define BARRIER_P(X) (GET_CODE (X) == BARRIER)
+/* Predicate yielding nonzero iff X is a subreg of a register. */
+#define SUBREG_REG_P(X) \
+ (GET_CODE (X) == SUBREG && REG_P (SUBREG_REG (X)))
+
+/* Predicate yielding nonzero iff X is a register or subreg of a register. */
+#define REG_SUBREG_P(X) \
+ (REG_P (X) || SUBREG_REG_P(X))
+
/* Predicate yielding nonzero iff X is a data for a jump table. */
#define JUMP_TABLE_DATA_P(INSN) \
(JUMP_P (INSN) && (GET_CODE (PATTERN (INSN)) == ADDR_VEC || \
Index: see.c
===================================================================
--- see.c (revision 148516)
+++ see.c (working copy)
@@ -738,9 +738,7 @@ see_get_extension_data (rtx extension, e
if (GET_CODE (rhs) != SIGN_EXTEND && GET_CODE (rhs) != ZERO_EXTEND)
return NOT_RELEVANT;
- if (!REG_P (XEXP (rhs, 0))
- && !(GET_CODE (XEXP (rhs, 0)) == SUBREG
- && REG_P (SUBREG_REG (XEXP (rhs, 0)))))
+ if (!REG_SUBREG_P (XEXP (rhs, 0)))
return NOT_RELEVANT;
*source_mode = GET_MODE (XEXP (rhs, 0));
@@ -1432,12 +1430,8 @@ see_want_to_be_merged_with_extension (rt
rtx sub = XVECEXP (pat, 0, i);
if (GET_CODE (sub) == SET
- && (REG_P (SET_DEST (sub))
- || (GET_CODE (SET_DEST (sub)) == SUBREG
- && REG_P (SUBREG_REG (SET_DEST (sub)))))
- && (REG_P (SET_SRC (sub))
- || (GET_CODE (SET_SRC (sub)) == SUBREG
- && REG_P (SUBREG_REG (SET_SRC (sub))))))
+ && REG_SUBREG_P (SET_DEST (sub))
+ && REG_SUBREG_P (SET_SRC (sub)))
{
/* This is a simple move SET. */
if (type == DEF_EXTENSION
@@ -1464,12 +1458,8 @@ see_want_to_be_merged_with_extension (rt
else
{
if (code == SET
- && (REG_P (SET_DEST (pat))
- || (GET_CODE (SET_DEST (pat)) == SUBREG
- && REG_P (SUBREG_REG (SET_DEST (pat)))))
- && (REG_P (SET_SRC (pat))
- || (GET_CODE (SET_SRC (pat)) == SUBREG
- && REG_P (SUBREG_REG (SET_SRC (pat))))))
+ && REG_SUBREG_P (SET_DEST (pat))
+ && REG_SUBREG_P (SET_SRC (pat)))
/* This is a simple move SET. */
return false;
}
@@ -2509,9 +2499,7 @@ see_def_extension_not_merged (struct see
gcc_assert (GET_CODE (rhs) == SIGN_EXTEND
|| GET_CODE (rhs) == ZERO_EXTEND);
dest_reg = XEXP (rhs, 0);
- gcc_assert (REG_P (dest_reg)
- || (GET_CODE (dest_reg) == SUBREG
- && REG_P (SUBREG_REG (dest_reg))));
+ gcc_assert (REG_SUBREG_P (dest_reg));
dest_real_reg = REG_P (dest_reg) ? dest_reg : SUBREG_REG (dest_reg);
dest_mode = GET_MODE (dest_reg);
@@ -2860,8 +2848,7 @@ see_merge_one_def_extension (void **slot
&& GET_MODE (SET_DEST (*sub)) == source_mode
&& ((REG_P (SET_DEST (*sub))
&& REGNO (SET_DEST (*sub)) == REGNO (source_extension_reg))
- || (GET_CODE (SET_DEST (*sub)) == SUBREG
- && REG_P (SUBREG_REG (SET_DEST (*sub)))
+ || (SUBREG_REG_P (SET_DEST (*sub))
&& (REGNO (SUBREG_REG (SET_DEST (*sub))) ==
REGNO (source_extension_reg)))))
{
@@ -2892,8 +2879,7 @@ see_merge_one_def_extension (void **slot
&& GET_MODE (SET_DEST (*pat)) == source_mode
&& ((REG_P (SET_DEST (*pat))
&& REGNO (SET_DEST (*pat)) == REGNO (source_extension_reg))
- || (GET_CODE (SET_DEST (*pat)) == SUBREG
- && REG_P (SUBREG_REG (SET_DEST (*pat)))
+ || (SUBREG_REG_P (SET_DEST (*pat))
&& (REGNO (SUBREG_REG (SET_DEST (*pat))) ==
REGNO (source_extension_reg)))))
{
Index: simplify-rtx.c
===================================================================
--- simplify-rtx.c (revision 148516)
+++ simplify-rtx.c (working copy)
@@ -866,8 +866,7 @@ simplify_unary_operation_1 (enum rtx_cod
if (! POINTERS_EXTEND_UNSIGNED
&& mode == Pmode && GET_MODE (op) == ptr_mode
&& (CONSTANT_P (op)
- || (GET_CODE (op) == SUBREG
- && REG_P (SUBREG_REG (op))
+ || (SUBREG_REG_P(op)
&& REG_POINTER (SUBREG_REG (op))
&& GET_MODE (SUBREG_REG (op)) == Pmode)))
return convert_memory_address (Pmode, op);
@@ -888,8 +887,7 @@ simplify_unary_operation_1 (enum rtx_cod
if (POINTERS_EXTEND_UNSIGNED > 0
&& mode == Pmode && GET_MODE (op) == ptr_mode
&& (CONSTANT_P (op)
- || (GET_CODE (op) == SUBREG
- && REG_P (SUBREG_REG (op))
+ || (SUBREG_REG_P(op)
&& REG_POINTER (SUBREG_REG (op))
&& GET_MODE (SUBREG_REG (op)) == Pmode)))
return convert_memory_address (Pmode, op);