brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · dd48b0e Raw
68 lines · plain
1; RUN: opt -passes=loop-vectorize -force-vector-width=2 -S %s | FileCheck %s2 3; Test cases to make sure LV & loop versioning can handle loops with4; multiple exiting branches.5 6; Multiple branches exiting the loop to a unique exit block. The loop should7; be vectorized with versioning.8define void @multiple_exits_unique_exit_block(ptr %A, ptr %B, i64 %N) {9; CHECK-LABEL: @multiple_exits_unique_exit_block10; CHECK:       vector.memcheck:11; CHECK-LABEL: vector.body:12; CHECK:         %wide.load = load <2 x i32>, ptr {{.*}}, align 413; CHECK:         store <2 x i32> %wide.load, ptr {{.*}}, align 414; CHECK:         br15;16entry:17  br label %loop.header18 19loop.header:20  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]21  %cond.0 = icmp eq i64 %iv, %N22  br i1 %cond.0, label %exit, label %for.body23 24for.body:25  %A.gep = getelementptr inbounds i32, ptr %A, i64 %iv26  %lv = load i32, ptr %A.gep, align 427  %B.gep = getelementptr inbounds i32, ptr %B, i64 %iv28  store i32 %lv, ptr %B.gep, align 429  %iv.next = add nuw i64 %iv, 130  %cond.1 = icmp ult i64 %iv.next, 100031  br i1 %cond.1, label %loop.header, label %exit32 33exit:34  ret void35}36 37 38; Multiple branches exiting the loop to different blocks. Currently this is not supported.39define i32 @multiple_exits_multiple_exit_blocks(ptr %A, ptr %B, i64 %N) {40; CHECK-LABEL: @multiple_exits_multiple_exit_blocks41; CHECK-NEXT:    entry:42; CHECK:           br label %loop.header43; CHECK-NOT:      <2 x i32>44;45entry:46  br label %loop.header47 48loop.header:49  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]50  %cond.0 = icmp eq i64 %iv, %N51  br i1 %cond.0, label %exit.0, label %for.body52 53for.body:54  %A.gep = getelementptr inbounds i32, ptr %A, i64 %iv55  %lv = load i32, ptr %A.gep, align 456  %B.gep = getelementptr inbounds i32, ptr %B, i64 %iv57  store i32 %lv, ptr %B.gep, align 458  %iv.next = add nuw i64 %iv, 159  %cond.1 = icmp ult i64 %iv.next, 100060  br i1 %cond.1, label %loop.header, label %exit.161 62exit.0:63  ret i32 164 65exit.1:66  ret i32 267}68