public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114502] New: Missed sccp final value with `a = -a`
@ 2024-03-27 21:02 pinskia at gcc dot gnu.org
  2024-03-27 21:07 ` [Bug tree-optimization/114502] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-27 21:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114502
           Summary: Missed sccp final value with `a = -a`
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Inspired by PR 114485 and PR 114476. I noticed that SCCP is not figuring out
what happens when just doing negative of the value. These days we do handle
`^&|` so handling unary - should be in a similar way I suspect.
Testcase:
```

[[gnu::noipa]]
unsigned f(unsigned c) {
  for (int i = 0; i < 1024; i ++) {
    c *= -1;
  }
  return c;
}
```

Note non-constant loop bounds handling is in a different bug report even.

The above should be optimized to just `return -c;` for -O2; We do optimize it
at -O3 but that is because the complete loop unroller figures out the cost for
the loop is nothing.

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

* [Bug tree-optimization/114502] Missed sccp final value with `a = -a`
  2024-03-27 21:02 [Bug tree-optimization/114502] New: Missed sccp final value with `a = -a` pinskia at gcc dot gnu.org
@ 2024-03-27 21:07 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-27 21:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=112104

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Non-constant loop bounds is PR 112104.

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

end of thread, other threads:[~2024-03-27 21:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-27 21:02 [Bug tree-optimization/114502] New: Missed sccp final value with `a = -a` pinskia at gcc dot gnu.org
2024-03-27 21:07 ` [Bug tree-optimization/114502] " 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).