Commit 4ca29add by Richard Sandiford Committed by Richard Sandiford

loop-iv.c: Include rtl-iter.h.

gcc/
	* loop-iv.c: Include rtl-iter.h.
	(find_single_def_src): New function.
	(replace_single_def_regs): Turn from being a for_each_rtx callback
	to being a function that examines each subrtx itself.
	(replace_in_expr, simplify_using_initial_values): Update accordingly.

From-SVN: r214645
parent e7c44276
2014-08-28 Richard Sandiford <rdsandiford@googlemail.com> 2014-08-28 Richard Sandiford <rdsandiford@googlemail.com>
* loop-iv.c: Include rtl-iter.h.
(find_single_def_src): New function.
(replace_single_def_regs): Turn from being a for_each_rtx callback
to being a function that examines each subrtx itself.
(replace_in_expr, simplify_using_initial_values): Update accordingly.
2014-08-28 Richard Sandiford <rdsandiford@googlemail.com>
* jump.c (eh_returnjump_p_1): Delete. * jump.c (eh_returnjump_p_1): Delete.
(eh_returnjump_p): Use FOR_EACH_SUBRTX rather than for_each_rtx. (eh_returnjump_p): Use FOR_EACH_SUBRTX rather than for_each_rtx.
Remove handling of null rtxes. Remove handling of null rtxes.
......
...@@ -62,6 +62,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -62,6 +62,7 @@ along with GCC; see the file COPYING3. If not see
#include "df.h" #include "df.h"
#include "hash-table.h" #include "hash-table.h"
#include "dumpfile.h" #include "dumpfile.h"
#include "rtl-iter.h"
/* Possible return values of iv_get_reaching_def. */ /* Possible return values of iv_get_reaching_def. */
...@@ -1398,33 +1399,27 @@ simple_rhs_p (rtx rhs) ...@@ -1398,33 +1399,27 @@ simple_rhs_p (rtx rhs)
} }
} }
/* If REG has a single definition, replace it with its known value in EXPR. /* If REGNO has a single definition, return its known value, otherwise return
Callback for for_each_rtx. */ null. */
static int static rtx
replace_single_def_regs (rtx *reg, void *expr1) find_single_def_src (unsigned int regno)
{ {
unsigned regno;
df_ref adef; df_ref adef;
rtx set, src; rtx set, src;
rtx *expr = (rtx *)expr1;
if (!REG_P (*reg))
return 0;
regno = REGNO (*reg);
for (;;) for (;;)
{ {
rtx note; rtx note;
adef = DF_REG_DEF_CHAIN (regno); adef = DF_REG_DEF_CHAIN (regno);
if (adef == NULL || DF_REF_NEXT_REG (adef) != NULL if (adef == NULL || DF_REF_NEXT_REG (adef) != NULL
|| DF_REF_IS_ARTIFICIAL (adef)) || DF_REF_IS_ARTIFICIAL (adef))
return -1; return NULL_RTX;
set = single_set (DF_REF_INSN (adef)); set = single_set (DF_REF_INSN (adef));
if (set == NULL || !REG_P (SET_DEST (set)) if (set == NULL || !REG_P (SET_DEST (set))
|| REGNO (SET_DEST (set)) != regno) || REGNO (SET_DEST (set)) != regno)
return -1; return NULL_RTX;
note = find_reg_equal_equiv_note (DF_REF_INSN (adef)); note = find_reg_equal_equiv_note (DF_REF_INSN (adef));
...@@ -1443,10 +1438,29 @@ replace_single_def_regs (rtx *reg, void *expr1) ...@@ -1443,10 +1438,29 @@ replace_single_def_regs (rtx *reg, void *expr1)
break; break;
} }
if (!function_invariant_p (src)) if (!function_invariant_p (src))
return -1; return NULL_RTX;
*expr = simplify_replace_rtx (*expr, *reg, src); return src;
return 1; }
/* If any registers in *EXPR that have a single definition, try to replace
them with the known-equivalent values. */
static void
replace_single_def_regs (rtx *expr)
{
subrtx_var_iterator::array_type array;
repeat:
FOR_EACH_SUBRTX_VAR (iter, array, *expr, NONCONST)
{
rtx x = *iter;
if (REG_P (x))
if (rtx new_x = find_single_def_src (REGNO (x)))
{
*expr = simplify_replace_rtx (*expr, x, new_x);
goto repeat;
}
}
} }
/* A subroutine of simplify_using_initial_values, this function examines INSN /* A subroutine of simplify_using_initial_values, this function examines INSN
...@@ -1491,8 +1505,7 @@ replace_in_expr (rtx *expr, rtx dest, rtx src) ...@@ -1491,8 +1505,7 @@ replace_in_expr (rtx *expr, rtx dest, rtx src)
*expr = simplify_replace_rtx (*expr, dest, src); *expr = simplify_replace_rtx (*expr, dest, src);
if (old == *expr) if (old == *expr)
return; return;
while (for_each_rtx (expr, replace_single_def_regs, expr) != 0) replace_single_def_regs (expr);
continue;
} }
/* Checks whether A implies B. */ /* Checks whether A implies B. */
...@@ -1937,9 +1950,7 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr) ...@@ -1937,9 +1950,7 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
gcc_assert (op == UNKNOWN); gcc_assert (op == UNKNOWN);
for (;;) replace_single_def_regs (expr);
if (for_each_rtx (expr, replace_single_def_regs, expr) == 0)
break;
if (CONSTANT_P (*expr)) if (CONSTANT_P (*expr))
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment