llvm-project/llvm/test/Transforms/LoopUnswitch/convergent-hoist-modified.ll
David Stenberg 7a1029fd1e Reland "[LoopUnswitch] Fix incorrect Modified status"
Relanded since the buildbot issue was unrelated to this commit.

When hoisting simple values out from a loop, and an optsize attribute, a
convergent call, or an invoke instruction hindered the pass from
unswitching the loop, the pass would return an incorrect Modified
status.

This was caught using the check introduced by D80916.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D86085
2020-08-20 11:52:09 +02:00

43 lines
1.5 KiB
LLVM

; RUN: opt -loop-unswitch -enable-new-pm=0 %s -S | FileCheck %s
; When hoisting simple values out from a loop, and not being able to unswitch
; the loop due to the convergent call, the pass would return an incorrect
; Modified status. This was caught by the pass return status check that is
; hidden under EXPENSIVE_CHECKS.
; CHECK-LABEL: entry:
; CHECK-NEXT: %0 = call i32 @llvm.objectsize.i32.p0i8(i8* bitcast (%struct.anon* @b to i8*), i1 false, i1 false, i1 false)
; CHECK-NEXT: %1 = icmp uge i32 %0, 1
; CHECK-NEXT: br label %for.cond
%struct.anon = type { i16 }
@b = global %struct.anon zeroinitializer, align 1
; Function Attrs: nounwind
define i16 @c() #0 {
entry:
br label %for.cond
for.cond: ; preds = %cont, %entry
br label %for.inc
for.inc: ; preds = %for.cond
%0 = call i32 @llvm.objectsize.i32.p0i8(i8* bitcast (%struct.anon* @b to i8*), i1 false, i1 false, i1 false)
%1 = icmp uge i32 %0, 1
br i1 %1, label %cont, label %cont
cont: ; preds = %for.inc
call void @conv() convergent
%2 = load i16, i16* getelementptr inbounds (%struct.anon, %struct.anon* @b, i32 0, i32 0), align 1
br label %for.cond
}
; Function Attrs: nounwind readnone speculatable willreturn
declare i32 @llvm.objectsize.i32.p0i8(i8*, i1 immarg, i1 immarg, i1 immarg) #1
declare void @conv() convergent
attributes #0 = { nounwind }
attributes #1 = { nounwind readnone speculatable willreturn }