|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt -p loop-vectorize -enable-early-exit-vectorization -force-vector-width=4 \ |
| 3 | +; RUN: -debug-only=loop-vectorize -S %s 2>%t | FileCheck --check-prefix=VF4IC4 %s |
| 4 | +; RUN: cat %t | FileCheck --check-prefix=DEBUG %s |
| 5 | + |
| 6 | +declare void @init_mem(ptr, i64); |
| 7 | + |
| 8 | +; DEBUG: Interleaving not supported for loops with uncountable early exits |
| 9 | + |
| 10 | +define i64 @multi_exiting_to_different_exits_live_in_exit_values() { |
| 11 | +; VF4IC4-LABEL: define i64 @multi_exiting_to_different_exits_live_in_exit_values() { |
| 12 | +; VF4IC4-NEXT: [[ENTRY:.*]]: |
| 13 | +; VF4IC4-NEXT: [[SRC:%.*]] = alloca [128 x i32], align 4 |
| 14 | +; VF4IC4-NEXT: call void @init_mem(ptr [[SRC]]) |
| 15 | +; VF4IC4-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]] |
| 16 | +; VF4IC4: [[VECTOR_PH]]: |
| 17 | +; VF4IC4-NEXT: br label %[[VECTOR_BODY:.*]] |
| 18 | +; VF4IC4: [[VECTOR_BODY]]: |
| 19 | +; VF4IC4-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ] |
| 20 | +; VF4IC4-NEXT: [[TMP0:%.*]] = getelementptr inbounds i32, ptr [[SRC]], i64 [[INDEX]] |
| 21 | +; VF4IC4-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i32 0 |
| 22 | +; VF4IC4-NEXT: [[WIDE_LOAD:%.*]] = load <4 x i32>, ptr [[TMP1]], align 4 |
| 23 | +; VF4IC4-NEXT: [[TMP2:%.*]] = icmp eq <4 x i32> [[WIDE_LOAD]], splat (i32 10) |
| 24 | +; VF4IC4-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4 |
| 25 | +; VF4IC4-NEXT: [[TMP3:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP2]]) |
| 26 | +; VF4IC4-NEXT: [[TMP4:%.*]] = icmp eq i64 [[INDEX_NEXT]], 128 |
| 27 | +; VF4IC4-NEXT: [[TMP5:%.*]] = or i1 [[TMP3]], [[TMP4]] |
| 28 | +; VF4IC4-NEXT: br i1 [[TMP5]], label %[[MIDDLE_SPLIT:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]] |
| 29 | +; VF4IC4: [[MIDDLE_SPLIT]]: |
| 30 | +; VF4IC4-NEXT: br i1 [[TMP3]], label %[[VECTOR_EARLY_EXIT:.*]], label %[[MIDDLE_BLOCK:.*]] |
| 31 | +; VF4IC4: [[MIDDLE_BLOCK]]: |
| 32 | +; VF4IC4-NEXT: br i1 true, label %[[E2:.*]], label %[[SCALAR_PH]] |
| 33 | +; VF4IC4: [[VECTOR_EARLY_EXIT]]: |
| 34 | +; VF4IC4-NEXT: br label %[[E1:.*]] |
| 35 | +; VF4IC4: [[SCALAR_PH]]: |
| 36 | +; VF4IC4-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 128, %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ] |
| 37 | +; VF4IC4-NEXT: br label %[[LOOP_HEADER:.*]] |
| 38 | +; VF4IC4: [[LOOP_HEADER]]: |
| 39 | +; VF4IC4-NEXT: [[IV:%.*]] = phi i64 [ [[INC:%.*]], %[[LOOP_LATCH:.*]] ], [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ] |
| 40 | +; VF4IC4-NEXT: [[GEP_SRC:%.*]] = getelementptr inbounds i32, ptr [[SRC]], i64 [[IV]] |
| 41 | +; VF4IC4-NEXT: [[L:%.*]] = load i32, ptr [[GEP_SRC]], align 4 |
| 42 | +; VF4IC4-NEXT: [[C_1:%.*]] = icmp eq i32 [[L]], 10 |
| 43 | +; VF4IC4-NEXT: br i1 [[C_1]], label %[[E1]], label %[[LOOP_LATCH]] |
| 44 | +; VF4IC4: [[LOOP_LATCH]]: |
| 45 | +; VF4IC4-NEXT: [[INC]] = add nuw i64 [[IV]], 1 |
| 46 | +; VF4IC4-NEXT: [[C_2:%.*]] = icmp eq i64 [[INC]], 128 |
| 47 | +; VF4IC4-NEXT: br i1 [[C_2]], label %[[E2]], label %[[LOOP_HEADER]], !llvm.loop [[LOOP3:![0-9]+]] |
| 48 | +; VF4IC4: [[E1]]: |
| 49 | +; VF4IC4-NEXT: [[P1:%.*]] = phi i64 [ 0, %[[LOOP_HEADER]] ], [ 0, %[[VECTOR_EARLY_EXIT]] ] |
| 50 | +; VF4IC4-NEXT: ret i64 [[P1]] |
| 51 | +; VF4IC4: [[E2]]: |
| 52 | +; VF4IC4-NEXT: [[P2:%.*]] = phi i64 [ 1, %[[LOOP_LATCH]] ], [ 1, %[[MIDDLE_BLOCK]] ] |
| 53 | +; VF4IC4-NEXT: ret i64 [[P2]] |
| 54 | +; |
| 55 | +entry: |
| 56 | + %src = alloca [128 x i32] |
| 57 | + call void @init_mem(ptr %src) |
| 58 | + br label %loop.header |
| 59 | + |
| 60 | +loop.header: |
| 61 | + %iv = phi i64 [ %inc, %loop.latch ], [ 0, %entry ] |
| 62 | + %gep.src = getelementptr inbounds i32, ptr %src, i64 %iv |
| 63 | + %l = load i32, ptr %gep.src |
| 64 | + %c.1 = icmp eq i32 %l, 10 |
| 65 | + br i1 %c.1, label %e1, label %loop.latch |
| 66 | + |
| 67 | +loop.latch: |
| 68 | + %inc = add nuw i64 %iv, 1 |
| 69 | + %c.2 = icmp eq i64 %inc, 128 |
| 70 | + br i1 %c.2, label %e2, label %loop.header, !llvm.loop !0 |
| 71 | + |
| 72 | +e1: |
| 73 | + %p1 = phi i64 [ 0, %loop.header ] |
| 74 | + ret i64 %p1 |
| 75 | + |
| 76 | +e2: |
| 77 | + %p2 = phi i64 [ 1, %loop.latch ] |
| 78 | + ret i64 %p2 |
| 79 | +} |
| 80 | + |
| 81 | +!0 = distinct !{!0, !1} |
| 82 | +!1 = !{!"llvm.loop.interleave.count", i32 4} |
| 83 | +;. |
| 84 | +; VF4IC4: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]], [[META2:![0-9]+]]} |
| 85 | +; VF4IC4: [[META1]] = !{!"llvm.loop.isvectorized", i32 1} |
| 86 | +; VF4IC4: [[META2]] = !{!"llvm.loop.unroll.runtime.disable"} |
| 87 | +; VF4IC4: [[LOOP3]] = distinct !{[[LOOP3]], [[META2]], [[META1]]} |
| 88 | +;. |
0 commit comments