-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[x86] Backend hangs during CodeGenPrepare
due to infinitely sinking cmp
expression
#58538
Labels
Comments
@llvm/issue-subscribers-backend-x86 |
; Original
define i32 @f() {
BB:
%RP = alloca i32, i32 20, align 4
%L = load i32, ptr %RP, align 4
%G = getelementptr i32, ptr %RP, i32 1
%C4 = icmp eq i32 %L, 0
%G3 = getelementptr i32, ptr %G, i32 4
br label %BB3
BB3: ; preds = %BB3, %BB
%G1 = getelementptr i1, ptr %G3, i1 %C4
br i1 false, label %BB3, label %BB1
BB1: ; preds = %BB3
%S = select i1 %C4, ptr %G3, ptr %G1
%L1 = load i32, ptr %S, align 4
ret i32 %L1
} ; Iteration 1
define i32 @f() {
BB:
%RP = alloca i32, i32 20, align 4
%L = load i32, ptr %RP, align 4
%G = getelementptr i32, ptr %RP, i32 1
%G3 = getelementptr i32, ptr %G, i32 4
br label %BB3
BB3: ; preds = %BB3, %BB
%0 = icmp eq i32 %L, 0
%G1 = getelementptr i1, ptr %G3, i1 %0
br i1 false, label %BB3, label %BB1
BB1: ; preds = %BB3
%1 = icmp eq i32 %L, 0
%S1 = select i1 %1, i1 false, i1 %0
%S = select i1 %1, ptr %G3, ptr %G1
%L1 = load i32, ptr %S, align 4
ret i32 %L1
} I believe the root cause is that after the first iteration, a new instruction is inserted: |
Candidate patch: https://reviews.llvm.org/D147041 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
The backend hangs with the following input during
CodeGenPrepare
when targetingx86_64
/i386
.Minimal Reproduction
https://godbolt.org/z/373K8TdhM
Code
Cause
sinkCmpExpression
keeps adding code for everyCodeGenPrepare
iteration so the loop is never broken.llvm-project/llvm/lib/CodeGen/CodeGenPrepare.cpp
Lines 1674 to 1738 in dacfdbc
Dump of IR for each iteration of
CodeGenPrepare
:The text was updated successfully, but these errors were encountered: