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