public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/55629] New: Missed value numbering to a constant
@ 2012-12-09 15:54 steven at gcc dot gnu.org
  2012-12-09 15:55 ` [Bug tree-optimization/55629] " steven at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: steven at gcc dot gnu.org @ 2012-12-09 15:54 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55629
           Summary: Missed value numbering to a constant
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: steven@gcc.gnu.org


Consider a classic example of non-distributivity of constant propagation:

int foo (int);
int foo (int c) {
  int a, b;
  if (c) { a = 3; b = 2; }
  else { a = 2; b = 3; }
  return a + b;
}

Value numbering should be able to determine that a+b=5. GCC successfully
optimizes the test case to just "return 5" with -ftree-pre, but with "only"
-ftree-fre (-O1) the equivalence is not noticed.


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

* [Bug tree-optimization/55629] Missed value numbering to a constant
  2012-12-09 15:54 [Bug tree-optimization/55629] New: Missed value numbering to a constant steven at gcc dot gnu.org
@ 2012-12-09 15:55 ` steven at gcc dot gnu.org
  2012-12-10  8:50 ` rguenth at gcc dot gnu.org
  2021-08-11  5:22 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: steven at gcc dot gnu.org @ 2012-12-09 15:55 UTC (permalink / raw)
  To: gcc-bugs


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

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-12-09
                 CC|                            |matz at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
      Known to work|                            |4.4.7, 4.6.3, 4.8.0
     Ever Confirmed|0                           |1


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

* [Bug tree-optimization/55629] Missed value numbering to a constant
  2012-12-09 15:54 [Bug tree-optimization/55629] New: Missed value numbering to a constant steven at gcc dot gnu.org
  2012-12-09 15:55 ` [Bug tree-optimization/55629] " steven at gcc dot gnu.org
@ 2012-12-10  8:50 ` rguenth at gcc dot gnu.org
  2021-08-11  5:22 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-10  8:50 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-10 08:50:12 UTC ---
I know that there is a duplicate of this bug, at least for a simpler
testcase ... but I can't find it right now.

The issue is that SCCVN does not do PHI-translation, that is,

  <bb 2>:
  if (c_3(D) != 0)
    goto <bb 3>;
  else
    goto <bb 4>;

  <bb 3>:
  a_4 = 3;
  b_5 = 2;
  goto <bb 5>;

  <bb 4>:
  a_6 = 2;
  b_7 = 3;

  <bb 5>:
  # a_1 = PHI <3(3), 2(4)>
  # b_2 = PHI <2(3), 3(4)>
  _8 = a_1 + b_2;

SCCVN would need to lookup a_1 and b_2 on both incoming edges when it tries
to simplify a_1 + b_2, match up the results and if equal register the
simplification.

I'm not sure that handling this case (which would certainly be possible)
is worth the cost it has on all expressions that do _not_ simplify that way.
(of course we can see whether the value-numbers for a_1/b_2 do have
has_constants set).

Time for a value-number missed-optimization meta bug, there are quite some
special cases that we do not handle.


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

* [Bug tree-optimization/55629] Missed value numbering to a constant
  2012-12-09 15:54 [Bug tree-optimization/55629] New: Missed value numbering to a constant steven at gcc dot gnu.org
  2012-12-09 15:55 ` [Bug tree-optimization/55629] " steven at gcc dot gnu.org
  2012-12-10  8:50 ` rguenth at gcc dot gnu.org
@ 2021-08-11  5:22 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-11  5:22 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

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

end of thread, other threads:[~2021-08-11  5:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-09 15:54 [Bug tree-optimization/55629] New: Missed value numbering to a constant steven at gcc dot gnu.org
2012-12-09 15:55 ` [Bug tree-optimization/55629] " steven at gcc dot gnu.org
2012-12-10  8:50 ` rguenth at gcc dot gnu.org
2021-08-11  5:22 ` pinskia at gcc dot gnu.org

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).