Issue 176682
Summary Miscompilation at -O3 with profiled data using PGO
Labels new issue
Assignees
Reporter helloqirun
    Reproducible on a recent commit: af98aadc63637ac674d4

```
$ clang-trunk -v
clang version 22.0.0git (https://github.com/llvm/llvm-project.git af98aadc63637ac674d403c77ccba42b05a3d11c)
```

I have reduced the testcase. The profiling data is produced by

`$ llvm-profdata merge prof.txt -o prof.profdata`

Compile without PGO is good.

```
$ clang-trunk -O3 -msse4.2 aa-831991.c ; ./a.out
1

```

Miscompiles with PGO enabled.
```
$ clang-trunk -O3 -msse4.2 -fprofile-instr-use=prof.profdata   aa-831991.c ; ./a.out
0
```

The testcase as well as the profiling data (in txt):

```
$ cat aa-831991.c
int printf(const char *, ...);
short a, e;
int b = 1, aj;
char f;
unsigned c(char g) {
  b &= 0 >= g | 90;
  return 0;
}
short d(int g) { return a; }
static unsigned char func_28() {
  e = 0;
  for (; e != -22; --e)
    c(d((((e <= (0 > (((8 > e) > 3) > 5) || 1)) < 3) > 5 == f) >= e || 3) <
      e) &&
        7 && (5 || 5 > (7 || 1)) < 0;
  return 1;
}
int main() {
  for (; aj < 6; aj++)
    func_28();
 printf("%X\n", b);
}
```

```
$ cat prof.txt
a
1000537922509932317
67
2
3
2
9
3
9
9
2
1
9
3
8
1
4
0
8
7
8
7
9
1
0
0
8
0
0
7
8
6
3
1
7
1
2
6
4
5
3
5
9
5
9
5
7
1
5
2
4
0
7
6
0
1
7
7
2
4
6
8
1
0
8
4
3
5
0
2
:
70444406143875
57
1
4
9
5
7
1
1
3
4
2
5
0
4
1
7
1
7
2
9
4
8
9
3
9
6
6
6
9
5
1
0
4
6
2
7
3
1
7
2
5
9
9
5
8
4
4
5
1
0
5
5
5
3
0
4
1
4
aa-831991.c:func_28
413345032826402189
9
1
8
5
5
5
9
5
807
601
```


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to