1 ; RUN: opt < %s -passes=loop-predication -S | FileCheck %s
2 ; RUN: opt -S -passes='require<scalar-evolution>,loop-mssa(loop-predication)' -verify-memoryssa < %s 2>&1 | FileCheck %s
4 ;; This is a simplified copy of @unswitch_exit_form test that should trigger loop-predication
5 ;; activity and properly bail out when discovering that widenable check does not lead to deopt.
7 ;; Error checking is rather silly here - it should pass compilation successfully,
8 ;; in bad case it will just timeout.
10 define i32 @unswitch_exit_form_with_endless_loop(ptr %array, i32 %length, i32 %n, i1 %cond_0) {
11 ; CHECK-LABEL: @unswitch_exit_form_with_endless_loop
13 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
14 %exiplicit_guard_cond = and i1 %cond_0, %widenable_cond
15 br i1 %exiplicit_guard_cond, label %loop.preheader, label %not_really_a_deopt, !prof !0
21 ;; synthetic corner case that demonstrates the need for more careful traversal
22 ;; of unique successors when walking through the exit for profitability checks.
29 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
30 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
31 %within.bounds = icmp ult i32 %i, %length
32 br i1 %within.bounds, label %guarded, label %not_really_a_deopt, !prof !0
35 %i.i64 = zext i32 %i to i64
36 %array.i.ptr = getelementptr inbounds i32, ptr %array, i64 %i.i64
37 %array.i = load i32, ptr %array.i.ptr, align 4
38 store i32 0, ptr %array.i.ptr
39 %loop.acc.next = add i32 %loop.acc, %array.i
40 %i.next = add nuw i32 %i, 1
41 %continue = icmp ult i32 %i.next, %n
42 br i1 %continue, label %loop, label %exit
45 %result = phi i32 [ %loop.acc.next, %guarded ]
49 declare void @unknown()
51 declare i1 @llvm.experimental.widenable.condition()
52 declare i32 @llvm.experimental.deoptimize.i32(...)
54 !0 = !{!"branch_weights", i32 1048576, i32 1}
55 !1 = !{i32 1, i32 -2147483648}