70 lines · plain
1; RUN: opt -S -disable-output -unroll-partial-threshold=16 -debug-only=loop-unroll -passes='loop-unroll<runtime>' < %s 2>&1 | FileCheck %s2 3; REQUIRES: asserts4 5; This test is needed to make sure that the guard cost remains the same,6; independently on guard representation form (either intrinsic call or branch with7; widenable condition).8 9define void @test_guard_as_intrinsic(ptr %arr, i64 %n, i64 %bound) {10; CHECK-LABEL: Loop Unroll: F[test_guard_as_intrinsic] Loop %loop11; CHECK-NEXT: Loop Size = 812; CHECK-NEXT: runtime unrolling with count: 213entry:14 br label %loop15 16loop:17 %iv = phi i64 [0, %entry], [%iv.next, %loop]18 %gep = getelementptr i64, ptr %arr, i64 %iv19 %bound_check = icmp ult i64 %iv, %bound20 call void(i1, ...) @llvm.experimental.guard(i1 %bound_check) [ "deopt"() ]21 store i64 %iv, ptr %gep, align 822 store i64 %iv, ptr %gep, align 823 %iv.next = add i64 %iv, 124 %loop_cond = icmp ult i64 %iv, %n25 br i1 %loop_cond, label %loop, label %exit26 27exit:28 ret void29}30 31define void @test_guard_as_branch(ptr %arr, i64 %n, i64 %bound) {32; CHECK-LABEL: Loop Unroll: F[test_guard_as_branch] Loop %loop33; CHECK-NEXT: Loop Size = 834; CHECK-NEXT: runtime unrolling with count: 235entry:36 br label %loop37 38loop: ; preds = %guarded, %entry39 %iv = phi i64 [ 0, %entry ], [ %iv.next, %guarded ]40 %gep = getelementptr i64, ptr %arr, i64 %iv41 %bound_check = icmp ult i64 %iv, %bound42 %widenable_cond = call i1 @llvm.experimental.widenable.condition()43 %exiplicit_guard_cond = and i1 %bound_check, %widenable_cond44 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !045 46deopt: ; preds = %loop47 call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]48 ret void49 50guarded: ; preds = %loop51 store i64 %iv, ptr %gep, align 852 store i64 %iv, ptr %gep, align 853 %iv.next = add i64 %iv, 154 %loop_cond = icmp ult i64 %iv, %n55 br i1 %loop_cond, label %loop, label %exit56 57exit: ; preds = %guarded58 ret void59}60 61; Function Attrs: nocallback nofree nosync willreturn62declare void @llvm.experimental.guard(i1, ...) #063 64declare void @llvm.experimental.deoptimize.isVoid(...)65 66; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(inaccessiblemem: readwrite)67declare i1 @llvm.experimental.widenable.condition() #168 69!0 = !{!"branch_weights", i32 1048576, i32 1}70