[Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
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
[Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44462 --- Comment #5 from Richard Biener --- So we now (GCC 8+ at least) get : _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; [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.
[Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
--- 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
[Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
--- 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
[Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
--- 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|-00-00 00:00:00 |2010-06-08 08:49:03 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44462
[Bug tree-optimization/44462] Redundant looping pure functions whose return value is dead are not optimized out
--- 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