|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt -passes=loop-vectorize -debug-only=loop-vectorize \ |
| 3 | +; RUN: -scalable-vectorization=on -force-target-supports-scalable-vectors \ |
| 4 | +; RUN: -force-tail-folding-style=none -enable-csa-vectorization \ |
| 5 | +; RUN: -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue \ |
| 6 | +; RUN: -disable-output 2>&1 < %s | FileCheck %s |
| 7 | + |
| 8 | +; This function is generated from the following C/C++ program: |
| 9 | +; int simple_csa_int_select(int N, int *data, int a) { |
| 10 | +; int t = -1; |
| 11 | +; for (int i = 0; i < N; i++) { |
| 12 | +; if (a < data[i]) |
| 13 | +; t = data[i]; |
| 14 | +; } |
| 15 | +; return t; // use t |
| 16 | +; } |
| 17 | +define i32 @simple_csa_int_select(i32 %N, ptr %data, i64 %a) { |
| 18 | +entry: |
| 19 | + %cmp9 = icmp sgt i32 %N, 0 |
| 20 | + br i1 %cmp9, label %loop.preheader, label %exit |
| 21 | + |
| 22 | +loop.preheader: ; preds = %entry |
| 23 | + %wide.trip.count = zext i32 %N to i64 |
| 24 | + br label %loop |
| 25 | + |
| 26 | +exit: ; preds = %loop, %entry |
| 27 | + %t.0.lcssa = phi i32 [ -1, %entry ], [ %spec.select, %loop ] |
| 28 | + ret i32 %t.0.lcssa |
| 29 | + |
| 30 | +loop: ; preds = %loop.preheader, %loop |
| 31 | + %iv = phi i64 [ 0, %loop.preheader ], [ %iv.next, %loop ] |
| 32 | + %t.010 = phi i32 [ -1, %loop.preheader ], [ %spec.select, %loop ] |
| 33 | + %arrayidx = getelementptr inbounds i32, ptr %data, i64 %iv |
| 34 | + %0 = load i32, ptr %arrayidx, align 4 |
| 35 | + %1 = sext i32 %0 to i64 |
| 36 | + %cmp1 = icmp slt i64 %a, %1 |
| 37 | + %spec.select = select i1 %cmp1, i32 %0, i32 %t.010 |
| 38 | + %iv.next = add nuw nsw i64 %iv, 1 |
| 39 | + %exitcond.not = icmp eq i64 %iv.next, %wide.trip.count |
| 40 | + br i1 %exitcond.not, label %exit, label %loop |
| 41 | +} |
| 42 | + |
| 43 | +; CHECK: <x1> vector loop: { |
| 44 | +; CHECK-NEXT: vector.body: |
| 45 | +; CHECK-NEXT: SCALAR-PHI vp<%1> = phi ir<0>, vp<%index.next> |
| 46 | +; CHECK-NEXT: EMIT ir<%t.010> = csa-data-phi ir<poison>, ir<%spec.select> |
| 47 | +; CHECK-NEXT: EMIT vp<%csa.mask.phi> = csa-mask-phi ir<false> |
| 48 | +; CHECK-NEXT: vp<%2> = SCALAR-STEPS vp<%1>, ir<1> |
| 49 | +; CHECK-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%data>, vp<%2> |
| 50 | +; CHECK-NEXT: vp<%3> = vector-pointer ir<%arrayidx> |
| 51 | +; CHECK-NEXT: WIDEN ir<%6> = load vp<%3> |
| 52 | +; CHECK-NEXT: WIDEN-CAST ir<%7> = sext ir<%6> to i64 |
| 53 | +; CHECK-NEXT: WIDEN ir<%cmp1> = icmp slt ir<%a>, ir<%7> |
| 54 | +; CHECK-NEXT: EMIT vp<%csa.cond.anyof> = any-of ir<%cmp1> |
| 55 | +; CHECK-NEXT: EMIT vp<%csa.mask.sel> = csa-mask-sel ir<%cmp1>, vp<%csa.mask.phi>, vp<%csa.cond.anyof> |
| 56 | +; CHECK-NEXT: EMIT ir<%spec.select> = csa-data-update ir<%t.010>, ir<%cmp1>, ir<%6>, ir<%t.010>, vp<%csa.mask.sel>, vp<%csa.cond.anyof> |
| 57 | +; CHECK-NEXT: EMIT vp<%index.next> = add nuw vp<%1>, ir<%5> |
| 58 | +; CHECK-NEXT: EMIT branch-on-count vp<%index.next>, ir<%n.vec> |
| 59 | +; CHECK-NEXT: No successors |
| 60 | +; CHECK-NEXT: } |
| 61 | +; CHECK-NEXT: Successor(s): ir-bb<middle.block> |
| 62 | +; CHECK-NEXT: |
| 63 | +; CHECK-NEXT: ir-bb<middle.block>: |
| 64 | +; CHECK-NEXT: EMIT vp<%5> = extract-from-end ir<%spec.select>, ir<1> |
| 65 | +; CHECK-NEXT: EMIT vp<%6> = CSA-EXTRACT-SCALAR ir<-1>, vp<%csa.mask.sel>, ir<%spec.select> |
| 66 | +; CHECK-NEXT: EMIT vp<%cmp.n> = icmp eq vp<%0>, ir<%n.vec> |
| 67 | +; CHECK-NEXT: EMIT branch-on-cond vp<%cmp.n> |
| 68 | +; CHECK-NEXT: Successor(s): ir-bb<exit.loopexit>, ir-bb<scalar.ph> |
0 commit comments