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
[InstCombine] Infinite combine loop #48549
Comments
assigned to @rotateright |
Bugpoint reduction: opt -instcombine ; ModuleID = '' @a = external dso_local global i32, align 4 define dso_local void @b() local_unnamed_addr #0 { for.cond: ; preds = %for.body, %entry for.body: ; preds = %for.cond for.end: ; preds = %for.cond attributes #0 = { "tune-cpu"="generic" } !llvm.ident = !{#0} !0 = !{!"clang version 13.0.0"} |
The bug appears to be in InstCombine's SimplifyDemandedBits of a select. We may have conflicting motives in changing a select's constant operands into the least set bits vs. matching a cmp's operand (another min/max hack that could disappear with canonicalization to intrinsics). So we're ping-ponging between: I think there's a small fix to avoid that - will try to reduce further and confirm. |
This should fix the bug in trunk: I'm marking this as blocking the 12.0 release to see if we can still get it in there. As noted in the description, this was visible in the 11.0 release, but not before that. The bug was likely introduced with: |
Merged: 692808e |
Extended Description
Hi, all.
This code, s.c, is a valid program but makes Clang hung on at compile time at -O1 to -Os.
$cat s.c
int a;
void b() {
int *c = &a;
int *d = &a;
int **e = &d;
for (*c = 7; c <= 2; *c += 1) {
int **f = d;
*c = 0;
**e /= f ? (c ? 10 : **f) % (*c &= 6) : 0;
}
*d = (*d -= *c & **e != 4) && (4 != a) - **e & d == c;
int g = &d;
g++;
}
$time clang -c -w -O0 s.c
real 0m0.021s
user 0m0.011s
sys 0m0.010s
$clang -c -w -O1 test.cc
//endless compiling (the same as -O2,-O3, and -Os options)
$clang -v
clang version 13.0.0 (https://github.com/llvm/llvm-project 22f00f6)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Selected multilib: .;@m64
This problem only occurs in clang-trunk and clang-11.0.0 or clang-11.0.1, while other released versions from clang-10 downwards perform well in this case.
Thanks.
Haoxin
The text was updated successfully, but these errors were encountered: