This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 4/6] Add df_single_{def,use} helper functions
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 14 Jun 2014 20:47:46 +0100
- Subject: [PATCH 4/6] Add df_single_{def,use} helper functions
- Authentication-results: sourceware.org; auth=none
- References: <87a99ftha6 dot fsf at talisman dot default> <8761k3tgys dot fsf at talisman dot default>
IRA wants to know whether a particular insn has a single def or use.
That seems worth putting in a utility function, again to hide the
underlying representation a bit.
Richard
gcc/
* df.h (df_single_def, df_single_use): New functions.
* ira.c (find_moveable_pseudos): Use them.
Index: gcc/df.h
===================================================================
--- gcc/df.h 2014-06-14 20:09:44.725239874 +0100
+++ gcc/df.h 2014-06-14 20:09:50.254289996 +0100
@@ -1165,6 +1165,25 @@ df_get_artificial_uses (unsigned int bb_
return df_scan_get_bb_info (bb_index)->artificial_uses;
}
+/* If INSN defines exactly one register, return the associated reference,
+ otherwise return null. */
+
+static inline df_ref
+df_single_def (const df_insn_info *info)
+{
+ df_ref *defs = DF_INSN_INFO_DEFS (info);
+ return defs[0] && !defs[1] ? defs[0] : NULL;
+}
+
+/* If INSN uses exactly one register, return the associated reference,
+ otherwise return null. */
+
+static inline df_ref
+df_single_use (const df_insn_info *info)
+{
+ df_ref *uses = DF_INSN_INFO_USES (info);
+ return uses[0] && !uses[1] ? uses[0] : NULL;
+}
/* web */
Index: gcc/ira.c
===================================================================
--- gcc/ira.c 2014-06-14 20:09:44.726239882 +0100
+++ gcc/ira.c 2014-06-14 20:10:29.210640914 +0100
@@ -4437,20 +4437,19 @@ find_moveable_pseudos (void)
if (NONDEBUG_INSN_P (insn))
{
df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
- df_ref *u_rec, *d_rec;
df_ref def, use;
uid_luid[INSN_UID (insn)] = i++;
- u_rec = DF_INSN_INFO_USES (insn_info);
- d_rec = DF_INSN_INFO_DEFS (insn_info);
- if (d_rec[0] != NULL && d_rec[1] == NULL
- && u_rec[0] != NULL && u_rec[1] == NULL
- && DF_REF_REGNO (*u_rec) == DF_REF_REGNO (*d_rec)
- && !bitmap_bit_p (&set, DF_REF_REGNO (*u_rec))
+ def = df_single_def (insn_info);
+ use = df_single_use (insn_info);
+ if (use
+ && def
+ && DF_REF_REGNO (use) == DF_REF_REGNO (def)
+ && !bitmap_bit_p (&set, DF_REF_REGNO (use))
&& rtx_moveable_p (&PATTERN (insn), OP_IN))
{
- unsigned regno = DF_REF_REGNO (*u_rec);
+ unsigned regno = DF_REF_REGNO (use);
bitmap_set_bit (moveable, regno);
bitmap_set_bit (&set, regno);
bitmap_set_bit (&used, regno);
@@ -4487,16 +4486,16 @@ find_moveable_pseudos (void)
FOR_BB_INSNS (bb, insn)
if (NONDEBUG_INSN_P (insn))
{
+ df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
rtx def_insn, closest_use, note;
- df_ref *def_rec, def, use;
+ df_ref def, use;
unsigned regno;
bool all_dominated, all_local;
enum machine_mode mode;
- def_rec = DF_INSN_DEFS (insn);
+ def = df_single_def (insn_info);
/* There must be exactly one def in this insn. */
- def = *def_rec;
- if (!def || def_rec[1] || !single_set (insn))
+ if (!def || !single_set (insn))
continue;
/* This must be the only definition of the reg. We also limit
which modes we deal with so that we can assume we can generate