1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/test/Transforms/LoopSimplify/convergent.ll
Sameer Sahasrabuddhe 11bc679be9 [LoopSimplify] don't separate nested loops with convergent calls
Summary:
When a loop has multiple backedges, loop simplification attempts to
separate them out into nested loops. This results in incorrect control
flow in the presence of some functions like a GPU barrier. This change
skips the transformation when such "convergent" function calls are
present in the loop body.

Reviewed By: nhaehnle

Differential Revision: https://reviews.llvm.org/D80078
2020-05-19 09:22:39 +05:30

26 lines
522 B
LLVM

; RUN: opt < %s -S -loop-simplify | FileCheck %s
; Don't separate out nested loops if a convergent call is present
; CHECK-NOT: BB1.outer
; CHECK: BB1.backedge
define i32 @test(i1 %loop_cond, i1 %exit_cond, i32 %init) {
entry:
br label %BB1
BB1:
%indvar = phi i32 [%indvar, %BB1], [%inc, %BB2], [%init, %entry]
call void @f() convergent
br i1 %loop_cond, label %BB1, label %BB2
BB2:
%inc = add i32 %indvar, 1
br i1 %exit_cond, label %exit, label %BB1
exit:
ret i32 %inc
}
declare void @f() convergent