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 3 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. 6;; 7;; Error checking is rather silly here - it should pass compilation successfully, 8;; in bad case it will just timeout. 9;; 10define 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 12entry: 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 16 17not_really_a_deopt: 18 br label %looping 19 20looping: 21 ;; synthetic corner case that demonstrates the need for more careful traversal 22 ;; of unique successors when walking through the exit for profitability checks. 23 br label %looping 24 25loop.preheader: 26 br label %loop 27 28loop: 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 33 34guarded: 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 43 44exit: 45 %result = phi i32 [ %loop.acc.next, %guarded ] 46 ret i32 %result 47} 48 49declare void @unknown() 50 51declare i1 @llvm.experimental.widenable.condition() 52declare i32 @llvm.experimental.deoptimize.i32(...) 53 54!0 = !{!"branch_weights", i32 1048576, i32 1} 55!1 = !{i32 1, i32 -2147483648} 56!2 = !{i32 0, i32 50} 57