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 ICE in expand_cse_reciprocals (PR tree-optimization/42078)


On Thu, Nov 19, 2009 at 3:47 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
> On Nov 18, 2009, Alexandre Oliva <aoliva@redhat.com> wrote:
>
>> IMHO, the problem is that arg1 is being reused to hold its own
>> reciprocal. ?Should a different assignment of a newly-created SSA_NAME
>> be created instead, debug bind stmts would be automagically fixed upon
>> removal or replacement of the original assignment.
>
> I offer two patches below.
>
> They're built upon the understanding that reusing an SSA name's DEF for
> a different value is not kosher: it fails to update debug stmts and it
> might wreak havoc in any additional side information.
>
> gsi_replace will refuse to replace a stmt with one that sets a different
> SSA name, for similar reasons.
>
> The first patch reimplements the code that modified the call stmt in
> place, copying it instead, modifying the copy to set a different
> variable (just a different SSA name (*), in this case) to the modified
> value, inserting the copy before the original, and then removing the
> original stmt.
>
> Debug stmts that refer to the removed DEF are reset with the patch
> above. ?In order to enable the automatic propagation of debug stmts (and
> any other code that might be attempting to log or make sense of the
> transformations for any other purpose), we have to tell the compiler how
> the old DEF relates with the new one before removing the old one. ?This
> is what the second patch implements.
>
> Is the 1st ok to install? ?How about the 2nd, on top of the 1st?

I don't like the 2nd patch too much.  As of the first one I agree
with the rationale but the implementation looks ugly (and
at least would need a comment).

Wouldn't

   rarg1 = make_ssa_name (SSA_NAME_VAR (gimple_call_lhs (stmt1)), stmt1);
   release_defs (stmt1);
   gimple_call_set_lhs (stmt1, rarg1);
   gimple_call_set_fndecl (stmt1);
   update_stmt (stmt1);

work as well?  That avoids the stmt duplication.

In fact this exchanging of the LHS (or rather invalidating of the
SSA name value) should be a helper function that knows
the implementation details and avoids going through releasing
and allocating the name.

Richard.

>
> (*) using the same SSA base variable is a bit of a hack. ?It might be
> easier on the eyes of someone looking at the dumps to actually create a
> tmp_var named after “recip” or somesuch. ?I couldn't convince myself
> this would do us significant good, and this code was slightly shorter,
> so I went ahead with it.
>
>
>
>
> --
> Alexandre Oliva, freedom fighter ? ?http://FSFLA.org/~lxoliva/
> You must be the change you wish to see in the world. -- Gandhi
> Be Free! -- http://FSFLA.org/ ? FSF Latin America board member
> Free Software Evangelist ? ? ?Red Hat Brazil Compiler Engineer
>
>


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