public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102232] New: Missed arithmetic fold
@ 2021-09-07 15:22 llvm at rifkin dot dev
  2021-09-07 15:24 ` [Bug tree-optimization/102232] " llvm at rifkin dot dev
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: llvm at rifkin dot dev @ 2021-09-07 15:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102232
           Summary: Missed arithmetic fold
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: llvm at rifkin dot dev
  Target Milestone: ---

LLVM optimizes bar into tgt here but not foo.

https://godbolt.org/z/nhEjaoanx

int foo(int a, int b) {
    return b * (1 + a / b) - a;
}
int bar(int a, int b) {
    return b * (a / b) + b - a;
}
int tgt(int a, int b) {
    return b - a % b;
}

LLVM appears to miss this too.

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

end of thread, other threads:[~2022-02-23 21:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 15:22 [Bug tree-optimization/102232] New: Missed arithmetic fold llvm at rifkin dot dev
2021-09-07 15:24 ` [Bug tree-optimization/102232] " llvm at rifkin dot dev
2021-09-07 18:34 ` pinskia at gcc dot gnu.org
2021-09-07 18:43 ` pinskia at gcc dot gnu.org
2021-11-09  4:30 ` navidrahimi at microsoft dot com
2021-11-09  4:34 ` navidrahimi at microsoft dot com
2021-11-10 16:17 ` navidrahimi at microsoft dot com
2021-11-10 16:19 ` navidrahimi at microsoft dot com
2021-11-10 16:22 ` navidrahimi at microsoft dot com
2021-11-23  3:08 ` cvs-commit at gcc dot gnu.org
2022-02-23 21:26 ` roger at nextmovesoftware dot com

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