[PATCH, dataflow] PR47525 DCE fails to eliminate dead calls to pure functions

Richard Guenther richard.guenther@gmail.com
Mon Jan 31 12:46:00 GMT 2011


On Mon, Jan 31, 2011 at 1:21 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Sat, Jan 29, 2011 at 11:54 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
>> On Sat, Jan 29, 2011 at 00:06, Peter Bergner <bergner@vnet.ibm.com> wrote:
>>> Tracking down some test suite failures while doing a --with-cpu=power7 build,
>>> I noticed that DCE is no longer eliminating dead calls to const or pure
>>> function calls.  This is due to all global registers being added to every
>>> call's use and def chains, even though const functions won't reference them
>>> at all and pure functions won't set them.
>>>
>>> The following patch fixes that and has bootstrapped and regtested with
>>> no regressions.  This is a regression since it works in gcc 4.3, but
>>> fails in gcc 4.4, 4.5 and trunk, but I understand it only a performance
>>> issue and not a correctness issue.
>>>
>>> Is that patch OK?  If so, do we want this in mainline now or after 4.6
>>> has branched?
>>
>> Since this is a regression, ok for 4.6 but please bootstrap it on an
>> x86 machine too just for the sake of coverage.
>
> I don't think the testcase is valid.
>
> extern int link_failure (int) __attribute__ ((pure));
> extern void no_return (void) __attribute__ ((noreturn,pure));
> int
> main (void)
> {
>  if (link_failure (0) < 1)
>    no_return ();
>  return 0;
> }
>
> no_return might be implemented as
>
> no_return() { while (1);}
>
> which means we can't DCE either call.

Honza - you added that looping-const-or-pure stuff(?), I think we need
to treat pure and const annotated fns as looping (at least for functions
also marked noreturn).  OTOH, noreturn, pure does not make much
sense (it would just mean there's no side-effect apart from not returning).

Richard.

> Richard.
>
>> Paolo
>>
>



More information about the Gcc-patches mailing list