[QUESTION] About RTL optimization at forward propagation
xiezhiheng
xiezhiheng@huawei.com
Sat Mar 28 03:18:14 GMT 2020
Hi,
I find there exists some restricts in function fwprop preventing it to forward propagate addresses into loops.
/* Go through all the uses. df_uses_create will create new ones at the
end, and we'll go through them as well.
Do not forward propagate addresses into loops until after unrolling.
CSE did so because it was able to fix its own mess, but we are not. */
for (i = 0; i < DF_USES_TABLE_SIZE (); i++)
{
if (!propagations_left)
break;
df_ref use = DF_USES_GET (i);
if (use)
{
if (DF_REF_TYPE (use) == DF_REF_REG_USE
|| DF_REF_BB (use)->loop_father == NULL <<<<<<<<<<
/* The outer most loop is not really a loop. */
|| loop_outer (DF_REF_BB (use)->loop_father) == NULL)
forward_propagate_into (use, fwprop_addr_p);
else if (fwprop_addr_p)
forward_propagate_into (use, false);
}
}
And I have two questions.
1) What are the reasons or background for not forward propagating addresses into loops ?
2) Can we still forward propagate addresses if the def and use are in the same loop ?
I mean something like:
diff -Nurp a/gcc/fwprop.c b/gcc/fwprop.c
--- a/gcc/fwprop.c 2020-03-27 03:17:50.704000000 -0400
+++ b/gcc/fwprop.c 2020-03-27 04:58:35.148000000 -0400
@@ -1573,10 +1573,12 @@ fwprop (bool fwprop_addr_p)
df_ref use = DF_USES_GET (i);
if (use)
{
+ df_ref def = get_def_for_use (use);
if (DF_REF_TYPE (use) == DF_REF_REG_USE
|| DF_REF_BB (use)->loop_father == NULL
/* The outer most loop is not really a loop. */
- || loop_outer (DF_REF_BB (use)->loop_father) == NULL)
+ || loop_outer (DF_REF_BB (use)->loop_father) == NULL
+ || (def && DF_REF_BB (def)->loop_father == DF_REF_BB (use)->loop_father))
forward_propagate_into (use, fwprop_addr_p);
else if (fwprop_addr_p)
I would be grateful if anyone could help.
Best regards
More information about the Gcc
mailing list