-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wrong code at -O3 on x86_64-linux-gnu #50873
Comments
My bisection points to commit 9934a5b
llvm/include/llvm/Transforms/Utils/Local.h | 5 +++ |
https://godbolt.org/z/qn4Enffoc, I can not reproduce. Also this patch only handle switchinst, this testcase has no swtichinst. |
The C source is irrelevant; the IR has a switch, and https://reviews.llvm.org/D106056 appears to be at fault or exposing a bug somewhere else. Here's a reduced test for "opt -correlated-propagation" (it can probably be reduced further): define i8 @src(i8 %t0) { g.exit.1:; preds = %g.exit, %g.exit, %g.exit g.exit.2:; preds = %g.exit.1, %g.exit.1, %g.exit.1 .thread.2:; preds = %g.exit.2, %g.exit.2, %g.exit.2 .thread.3:; preds = %.thread.2, %.thread.2 |
Alive2 appears to confirm that the switch transform is at fault: |
I reverted the original patch, so we are not blocking anyone while investigating. Here's a further reduction that seems to make the problem obvious - if the default block is the same as any of the case blocks, we can't make it unreachable? |
I think it's safe to resolve this report. I reverted the offending patch with: And added a minimal test based on this example: ...so we should not fail in the same way. There's still an open question about another potential bug discussed in: |
Extended Description
It appears to be a recent regression.
$ clang-trunk -v
clang version 14.0.0 (https://github.com/llvm/llvm-project.git 4f5ba46)
$ clang-trunk abc.c ; ./a.out
0
$ clang-trunk -O2 abc.c ; ./a.out
$ cat abc.c
int a, c, d;
char e, f;
char(g)(char h, char i) { return i == 0 || h == -128 && i == 1 ? h : h % i; }
char k() {
int j;
d = 3;
for (;; d--)
for (;;) {
short b = g(d, e | d);
j = !b + 1;
f = (1 == b) * j;
c = b;
if (d)
break;
return 1;
}
}
int main() {
k();
printf("%X\n", a);
}
The text was updated successfully, but these errors were encountered: