-
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
[LoopUnroll] compile-time explosion with assumes at -O3 #49129
Comments
Unlike some of the other bugs, this one might not be an infinite loop, but a compile-time explosion from assumes. :) The IR coming out of the loop vectorizer has a lot of assumes like this: It's then stuck at loop-unroll. That might be why we only notice the problem at -O3 and not -O2. |
I reduced to this: define void @#49785 (i32 %d) { vector.ph: ; preds = %for.body4, %entry vector.body: ; preds = %vector.body, %vector.ph for.body4: ; preds = %vector.body for.end34: ; preds = %for.body4 declare void @llvm.assume(i1 noundef) #1 And it is taking a seemingly infinite time to compile with: opt -S 49785min.ll -loop-unroll -unroll-threshold=239 But changing the unroll-threshold lower appears to make this compile instantly, so maybe it is an infinite loop... |
We could blame/change a number of different passes in this example. The initial assume is created by SimplifyCFG. But we decided that was ok in https://reviews.llvm.org/D97306 (although we suggested using https://llvm.org/docs/LangRef.html#assume-operand-bundles - although I'm not sure how to do that for branch conditions). There may be a way to limit the damage that the LoopVectorizer is causing by duplicating the initial assume. If not, I think we will have to look at not duplicating assumes within LoopUnroll. |
Proposal: |
We took a different approach in: Committed at: IR test case derived from the source in this report added with: |
Extended Description
Hi all.
$cat small.c
#include <stdint.h>
int a, b, c, d;
uint16_t e;
void f() {
uint16_t *g = &e;
int8_t *i = &a;
for (c = 5; c <= 63; c++)
for (*g = 9; *g <= 60; *g += 1)
if ((e ^ b) != d) {
int8_t *j = a;
for (*j = 3; *j <= 32; *j += 1)
if (*j)
for (*i = 1; *i <= 30;)
*i &= 0 == c;
}
}
$clang -w -O3 small.c
//endless compiling
$clang -v
clang version 13.0.0 (https://github.com/llvm/llvm-project 850fced)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/7.5.0
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
Thanks,
Haoxin
The text was updated successfully, but these errors were encountered: