public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/104018] New: Comparison against 0 propagates into other statement causing no-CSE from happening
@ 2022-01-13 23:23 pinskia at gcc dot gnu.org
  2022-01-13 23:24 ` [Bug tree-optimization/104018] " pinskia at gcc dot gnu.org
  2022-01-14  8:08 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-13 23:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104018
           Summary: Comparison against 0 propagates into other statement
                    causing no-CSE from happening
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
int f(unsigned int a, unsigned int b) {
    if (a > 0) {
        return a == b;
    } else {
        return a == b;
    }
}
int f2(unsigned int a, unsigned int b) {
    if (a > 1) {
        return a == b;
    } else {
        return a == b;
    }
}

They should produce the same results but don't currently as in the first case
the >0 is turned into != 0 and then the 0 is propagated into the comparison and
then the comparison in the other BBSs are not able to be CSE'ed with the other
one.

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

* [Bug tree-optimization/104018] Comparison against 0 propagates into other statement causing no-CSE from happening
  2022-01-13 23:23 [Bug tree-optimization/104018] New: Comparison against 0 propagates into other statement causing no-CSE from happening pinskia at gcc dot gnu.org
@ 2022-01-13 23:24 ` pinskia at gcc dot gnu.org
  2022-01-14  8:08 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-13 23:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |12.0, 4.1.2
           Severity|normal                      |enhancement

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

* [Bug tree-optimization/104018] Comparison against 0 propagates into other statement causing no-CSE from happening
  2022-01-13 23:23 [Bug tree-optimization/104018] New: Comparison against 0 propagates into other statement causing no-CSE from happening pinskia at gcc dot gnu.org
  2022-01-13 23:24 ` [Bug tree-optimization/104018] " pinskia at gcc dot gnu.org
@ 2022-01-14  8:08 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-14  8:08 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-01-14
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The "unfortunate" thing is that FRE1 figures out they are equal but there's
no SSA name available with the value to replace the PHI node with ... it needs
PRE hoisting to apply the CSE which is too late.

It's DOM doing the equivalence propagation btw. (I think DOM is even the only
pass doing this).

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

end of thread, other threads:[~2022-01-14  8:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-13 23:23 [Bug tree-optimization/104018] New: Comparison against 0 propagates into other statement causing no-CSE from happening pinskia at gcc dot gnu.org
2022-01-13 23:24 ` [Bug tree-optimization/104018] " pinskia at gcc dot gnu.org
2022-01-14  8:08 ` rguenth 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).