This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR46834: when removing a phi node also remove the dead code using its LHS.


On Fri, Feb 4, 2011 at 17:19, Richard Guenther
<richard.guenther@gmail.com> wrote:
>> +
>> + ? ? ?/* Remove dead code using DEF. ?*/
>> + ? ? ?else if (gimple_assign_ssa_name_copy_p (stmt)
>> + ? ? ? ? ? ? ?&& !first_imm_use_stmt (&ii, gimple_assign_lhs (stmt)))
>> + ? ? ? {
>> + ? ? ? ? mark_virtual_ops_for_renaming (stmt);
>> + ? ? ? ? gsi = gsi_for_stmt (stmt);
>> + ? ? ? ? gsi_remove (&gsi, true);
>> + ? ? ? ? release_defs (stmt);
>
> That's a strange piece of code. ?And it just shifts the problem to the
> stmts that use the defs you just removed.

This call ensures that there are no other uses of the LHS of stmt:
>> +              && !first_imm_use_stmt (&ii, gimple_assign_lhs (stmt)))

> Thus, why do we call
> remove_phi at all when the PHI clearly isn't tivially dead?

We remove all the phi nodes that are in a reduction chain, for
example we rewrite this loop nest:

sum_0 = 0
loop_1
  sum_1 = phi (sum_0, sum_4)
  loop_2
    sum_2 = phi (sum_1, sum_3)
    sum_3 = sum_2 + x
  end_2
  sum_4 = phi (sum_3)
end_1
sum_5 = phi (sum_4)

into the following one:

A[0] = 0
loop_1
  loop_2
    A[0] = A[0] + x
  end_2
end_1

The detection of the reduction ensures that there are no computations
on the chain other than the reduction statement: sum_3 = sum_2 + x.

Sebastian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]