public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
       [not found] <bug-44462-4@http.gcc.gnu.org/bugzilla/>
@ 2021-05-05 13:49 ` rguenth at gcc dot gnu.org
  2021-05-10  9:45 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-05 13:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44462

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
So we now (GCC 8+ at least) get

  <bb 2> :
  _1 = i_am_pure (5);
  a_8 = _1 * 2;
  i_am_pure (8);
  return a_8;

after early DCE.  This is because we now do FRE before the first DCE which
4.5 didn't have (4.8 has that already).

So fixed for the testcase, not exactly in general though.

__attribute__ ((noinline,noclone))
int
i_am_pure (int a)
{
  if (a>10)
    __builtin_abort();
}

int main()
{
  i_am_pure (8);
  i_am_pure (8);
  return 0;
}

is still not "CSE"d.  The question is whether that happens in practice?

We do actually detect the "redundancy" during propagation but fail to
do anything in elimination - also because we don't properly track
"availability" here.  As a first step one could handle the cases
where the call has the same VUSE, but that only helps for pure calls,
not const ones.

There's also the case of aggregate returns which makes the calls
receive vops:

struct S { int x; };

__attribute__ ((noinline,noclone))
struct S
i_am_pure (int a)
{
  if (a>10)
    __builtin_abort();
}

int main()
{
  struct S x;
  x = i_am_pure (8);
  x = i_am_pure (8);
  return 0;
}

which we do not optimize at all.

int main ()
{
  struct S x;

  <bb 2> [local count: 1073741824]:
  x = i_am_pure (8);
  x = i_am_pure (8);
  x ={v} {CLOBBER};
  return 0;

we could DSE the LHS of the calls it seems.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
       [not found] <bug-44462-4@http.gcc.gnu.org/bugzilla/>
  2021-05-05 13:49 ` [Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out rguenth at gcc dot gnu.org
@ 2021-05-10  9:45 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-10  9:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44462
Bug 44462 depends on bug 100434, which changed state.

Bug 100434 Summary: DSE fails to DSE aggregate LHS.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100434

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
  2010-06-08  7:32 [Bug tree-optimization/44462] New: " hubicka at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-06-09  9:11 ` rguenther at suse dot de
@ 2010-06-09 10:30 ` hubicka at ucw dot cz
  3 siblings, 0 replies; 6+ messages in thread
From: hubicka at ucw dot cz @ 2010-06-09 10:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from hubicka at ucw dot cz  2010-06-09 10:29 -------
Subject: Re:  Redundant looping pure functions
        whose return value is dead are not optimized out

> > >Why do we remove register LHS in DCE again? 
> > 
> > Because it reduces the amount of garbage produced by expand :).
> 
> Which means the expander could drop it ...

This won't save us from not optimizing out functions returning void.  They can
be looping pure too (most of sanity checks are)

Honza


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44462


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
  2010-06-08  7:32 [Bug tree-optimization/44462] New: " hubicka at gcc dot gnu dot org
  2010-06-08  8:49 ` [Bug tree-optimization/44462] " rguenth at gcc dot gnu dot org
  2010-06-08 20:10 ` pinskia at gcc dot gnu dot org
@ 2010-06-09  9:11 ` rguenther at suse dot de
  2010-06-09 10:30 ` hubicka at ucw dot cz
  3 siblings, 0 replies; 6+ messages in thread
From: rguenther at suse dot de @ 2010-06-09  9:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenther at suse dot de  2010-06-09 09:10 -------
Subject: Re:  Redundant looping pure functions
 whose return value is dead are not optimized out

On Tue, 8 Jun 2010, pinskia at gcc dot gnu dot org wrote:

> ------- Comment #2 from pinskia at gcc dot gnu dot org  2010-06-08 20:10 -------
> >Why do we remove register LHS in DCE again? 
> 
> Because it reduces the amount of garbage produced by expand :).

Which means the expander could drop it ...

Richard.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44462


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
  2010-06-08  7:32 [Bug tree-optimization/44462] New: " hubicka at gcc dot gnu dot org
  2010-06-08  8:49 ` [Bug tree-optimization/44462] " rguenth at gcc dot gnu dot org
@ 2010-06-08 20:10 ` pinskia at gcc dot gnu dot org
  2010-06-09  9:11 ` rguenther at suse dot de
  2010-06-09 10:30 ` hubicka at ucw dot cz
  3 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-06-08 20:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2010-06-08 20:10 -------
>Why do we remove register LHS in DCE again? 

Because it reduces the amount of garbage produced by expand :).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44462


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
  2010-06-08  7:32 [Bug tree-optimization/44462] New: " hubicka at gcc dot gnu dot org
@ 2010-06-08  8:49 ` rguenth at gcc dot gnu dot org
  2010-06-08 20:10 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-08  8:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2010-06-08 08:49 -------
Hm?  The return values are removed as part of first DCE pass.

<bb 2>:
  D.2721_1 = i_am_pure (5);
  D.2722_2 = i_am_pure (5);
  a_3 = D.2721_1 + D.2722_2;
  i_am_pure (8);
  i_am_pure (8);
  return a_3;

and FRE/PRE do not value-number anything that does not DEF an SSA name
(nor something that defines something that is not used, so -fno-tree-dce
does not help here).

Why do we remove register LHS in DCE again?  I can fix VN easily to
also consider unused LHS on not dead stmts.

Thus, mine for -fno-tree-dce.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-06-08 08:49:03
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44462


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-10  9:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-44462-4@http.gcc.gnu.org/bugzilla/>
2021-05-05 13:49 ` [Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out rguenth at gcc dot gnu.org
2021-05-10  9:45 ` rguenth at gcc dot gnu.org
2010-06-08  7:32 [Bug tree-optimization/44462] New: " hubicka at gcc dot gnu dot org
2010-06-08  8:49 ` [Bug tree-optimization/44462] " rguenth at gcc dot gnu dot org
2010-06-08 20:10 ` pinskia at gcc dot gnu dot org
2010-06-09  9:11 ` rguenther at suse dot de
2010-06-09 10:30 ` hubicka at ucw dot cz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).