public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102920] New: [12 Regression] Wrong code with -O3
@ 2021-10-24 23:22 vsevolod.livinskij at frtk dot ru
  2021-10-25  3:02 ` [Bug tree-optimization/102920] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: vsevolod.livinskij at frtk dot ru @ 2021-10-24 23:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102920
           Summary: [12 Regression] Wrong code with -O3
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

https://godbolt.org/z/qn3dsxsW8

Reproducer:
#include <stdio.h>

unsigned short a = 42;
unsigned short b = 1;
long long int c = 1;
unsigned char var_120;
unsigned char var_123;

void test(unsigned short a, unsigned short b, long long int c)
__attribute__((noipa));

void test(unsigned short a, unsigned short b, long long c) {
    for (char i = 0; i < (char)c; i += 5)
        if (!b)
            var_120 = a;
        else
            var_123 = a;
}

int main() {
    test(a, b, c);
    printf("%hhu\n", var_123);
    //if (var_123 != 42)
    //    __builtin_abort();
}

Error:
>$ g++ -O3 small.cpp && ./a.out
0
>$ g++ -O2 small.cpp && ./a.out
42

GCC version:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/testing/gcc/bin_master/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /testing/gcc/gcc_src_master/configure --enable-multilib
--prefix=/testing/gcc/bin_master --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20211023 (experimental) (GCC) 
root@abe71269b867:/testing/result/S_1635079215/reduce# cat
/testing/gcc/gcc_rev.txt 
git://gcc.gnu.org/git/gcc.git:master
e3725624ec0735996a18e1a90317e230bef899ac

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

end of thread, other threads:[~2021-10-25  8:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-24 23:22 [Bug tree-optimization/102920] New: [12 Regression] Wrong code with -O3 vsevolod.livinskij at frtk dot ru
2021-10-25  3:02 ` [Bug tree-optimization/102920] " pinskia at gcc dot gnu.org
2021-10-25  6:51 ` rguenth at gcc dot gnu.org
2021-10-25  7:30 ` rguenth at gcc dot gnu.org
2021-10-25  8:28 ` cvs-commit at gcc dot gnu.org
2021-10-25  8:28 ` rguenth at gcc dot gnu.org
2021-10-25  8:58 ` 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).