public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/105142] New: [12 Regression] Wrong code with -O2
@ 2022-04-03 22:13 vsevolod.livinskiy at gmail dot com
  2022-04-03 22:20 ` [Bug tree-optimization/105142] [12 Regression] Wrong code with -O2 since r12-2591 jakub at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: vsevolod.livinskiy at gmail dot com @ 2022-04-03 22:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105142
           Summary: [12 Regression] Wrong code with -O2
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vsevolod.livinskiy at gmail dot com
  Target Milestone: ---

Link to the Compiler Explorer: https://godbolt.org/z/51v98a6fd

Reproducer:
#include <stdio.h>

long long int arr_248 = 3623214276426624192LL;
unsigned short arr_255;

void test() __attribute__((noipa));

char a = 42;
const long long &min(const long long &c, const long long &d) {
  return c < d ? c : d;
}
void test() { arr_255 = min(a, min(a, arr_248) + 5713568809962283044LL); }

int main() {
    test();
    printf("%u\n", arr_255);
    if (arr_255 != 42)
      __builtin_abort();
}

Error:
>$ g++ -O1 small.cpp && ./a.out
42
>$ g++ -O2 small.cpp && ./a.out
3300
Aborted (core dumped)

gcc version 12.0.1 20220401 (git://gcc.gnu.org/git/gcc.git:master
15d683d4f0b390b27c54a7c92c6e4f33195bdc93)

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

end of thread, other threads:[~2022-11-11 14:05 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-03 22:13 [Bug tree-optimization/105142] New: [12 Regression] Wrong code with -O2 vsevolod.livinskiy at gmail dot com
2022-04-03 22:20 ` [Bug tree-optimization/105142] [12 Regression] Wrong code with -O2 since r12-2591 jakub at gcc dot gnu.org
2022-04-03 22:33 ` jakub at gcc dot gnu.org
2022-04-04  7:27 ` rguenth at gcc dot gnu.org
2022-04-04  9:07 ` rguenth at gcc dot gnu.org
2022-04-04  9:25 ` jakub at gcc dot gnu.org
2022-04-04  9:26 ` jakub at gcc dot gnu.org
2022-04-04  9:28 ` rguenth at gcc dot gnu.org
2022-04-04  9:32 ` rguenth at gcc dot gnu.org
2022-04-04 10:11 ` rguenth at gcc dot gnu.org
2022-04-04 11:20 ` rguenth at gcc dot gnu.org
2022-04-04 12:43 ` rguenth at gcc dot gnu.org
2022-04-06  6:15 ` cvs-commit at gcc dot gnu.org
2022-04-06  6:17 ` rguenth at gcc dot gnu.org
2022-11-11 14:05 ` cvs-commit 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).