57 lines · plain
1; RUN: opt < %s -passes=loop-predication -S | FileCheck %s2; RUN: opt -S -passes='require<scalar-evolution>,loop-mssa(loop-predication)' -verify-memoryssa < %s 2>&1 | FileCheck %s3 4;; This is a simplified copy of @unswitch_exit_form test that should trigger loop-predication5;; 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_loop12entry:13 %widenable_cond = call i1 @llvm.experimental.widenable.condition()14 %exiplicit_guard_cond = and i1 %cond_0, %widenable_cond15 br i1 %exiplicit_guard_cond, label %loop.preheader, label %not_really_a_deopt, !prof !016 17not_really_a_deopt:18 br label %looping19 20looping:21 ;; synthetic corner case that demonstrates the need for more careful traversal22 ;; of unique successors when walking through the exit for profitability checks.23 br label %looping24 25loop.preheader:26 br label %loop27 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, %length32 br i1 %within.bounds, label %guarded, label %not_really_a_deopt, !prof !033 34guarded:35 %i.i64 = zext i32 %i to i6436 %array.i.ptr = getelementptr inbounds i32, ptr %array, i64 %i.i6437 %array.i = load i32, ptr %array.i.ptr, align 438 store i32 0, ptr %array.i.ptr39 %loop.acc.next = add i32 %loop.acc, %array.i40 %i.next = add nuw i32 %i, 141 %continue = icmp ult i32 %i.next, %n42 br i1 %continue, label %loop, label %exit43 44exit:45 %result = phi i32 [ %loop.acc.next, %guarded ]46 ret i32 %result47}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