|
| 1 | +; REQUIRES: asserts |
| 2 | + |
| 3 | +; RUN: opt -passes=loop-vectorize -debug-only=loop-vectorize \ |
| 4 | +; RUN: -force-tail-folding-style=data-with-evl \ |
| 5 | +; RUN: -prefer-predicate-over-epilogue=predicate-dont-vectorize \ |
| 6 | +; RUN: -mtriple=riscv64 -mattr=+v -riscv-v-vector-bits-max=128 -disable-output < %s 2>&1 | FileCheck --check-prefix=IF-EVL %s |
| 7 | + |
| 8 | +define void @first_order_recurrence(ptr noalias %A, ptr noalias %B, i64 %TC) { |
| 9 | +; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1' |
| 10 | +; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI |
| 11 | +; |
| 12 | +; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' { |
| 13 | +; IF-EVL-NEXT: Live-in vp<[[VF:%[0-9]+]]> = VF |
| 14 | +; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF |
| 15 | +; IF-EVL-NEXT: Live-in vp<[[VTC:%[0-9]+]]> = vector-trip-count |
| 16 | +; IF-EVL-NEXT: Live-in ir<%TC> = original trip-count |
| 17 | +; IF-EVL-EMPTY: |
| 18 | +; IF-EVL: ir-bb<entry>: |
| 19 | +; IF-EVL-NEXT: Successor(s): vector.ph |
| 20 | +; IF-EVL-EMPTY: |
| 21 | +; IF-EVL: vector.ph: |
| 22 | +; IF-EVL-NEXT: SCALAR-CAST vp<[[VF32:%[0-9]+]]> = trunc vp<[[VF]]> to i32 |
| 23 | +; IF-EVL-NEXT: Successor(s): vector loop |
| 24 | +; IF-EVL-EMPTY: |
| 25 | +; IF-EVL: <x1> vector loop: { |
| 26 | +; IF-EVL-NEXT: vector.body: |
| 27 | +; IF-EVL-NEXT: EMIT vp<[[IV:%[0-9]+]]> = CANONICAL-INDUCTION |
| 28 | +; IF-EVL-NEXT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI vp<[[EVL_PHI:%[0-9]+]]> = phi ir<0>, vp<[[IV_NEXT:%.+]]> |
| 29 | +; IF-EVL-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<[[FOR_PHI:%.+]]> = phi ir<33>, ir<[[LD:%.+]]> |
| 30 | +; IF-EVL-NEXT: SCALAR-PHI vp<[[PREV_EVL:%.+]]> = phi vp<[[VF32]]>, vp<[[EVL:%.+]]> |
| 31 | +; IF-EVL-NEXT: EMIT vp<[[AVL:%.+]]> = sub ir<%TC>, vp<[[EVL_PHI]]> |
| 32 | +; IF-EVL-NEXT: EMIT vp<[[EVL]]> = EXPLICIT-VECTOR-LENGTH vp<[[AVL]]> |
| 33 | +; IF-EVL-NEXT: vp<[[ST:%[0-9]+]]> = SCALAR-STEPS vp<[[EVL_PHI]]>, ir<1> |
| 34 | +; IF-EVL-NEXT: CLONE ir<[[GEP1:%.+]]> = getelementptr inbounds nuw ir<%A>, vp<[[ST]] |
| 35 | +; IF-EVL-NEXT: vp<[[PTR1:%[0-9]+]]> = vector-pointer ir<[[GEP1]]> |
| 36 | +; IF-EVL-NEXT: WIDEN ir<[[LD]]> = vp.load vp<[[PTR1]]>, vp<[[EVL]]> |
| 37 | +; IF-EVL-NEXT: WIDEN-INTRINSIC vp<[[SPLICE:%[0-9]+]]> = call llvm.experimental.vp.splice(ir<[[FOR_PHI]]>, ir<[[LD]]>, ir<-1>, ir<true>, vp<[[PREV_EVL]]>, vp<[[EVL]]>) |
| 38 | +; IF-EVL-NEXT: WIDEN ir<[[ADD:%.+]]> = vp.add nsw vp<[[SPLICE]]>, ir<[[LD]]>, vp<[[EVL]]> |
| 39 | +; IF-EVL-NEXT: CLONE ir<[[GEP2:%.+]]> = getelementptr inbounds nuw ir<%B>, vp<[[ST]]> |
| 40 | +; IF-EVL-NEXT: vp<[[PTR2:%[0-9]+]]> = vector-pointer ir<[[GEP2]]> |
| 41 | +; IF-EVL-NEXT: WIDEN vp.store vp<[[PTR2]]>, ir<[[ADD]]>, vp<[[EVL]]> |
| 42 | +; IF-EVL-NEXT: SCALAR-CAST vp<[[CAST:%[0-9]+]]> = zext vp<[[EVL]]> to i64 |
| 43 | +; IF-EVL-NEXT: EMIT vp<[[IV_NEXT]]> = add vp<[[CAST]]>, vp<[[EVL_PHI]]> |
| 44 | +; IF-EVL-NEXT: EMIT vp<[[IV_NEXT_EXIT:%.+]]> = add vp<[[IV]]>, vp<[[VFUF]]> |
| 45 | +; IF-EVL-NEXT: EMIT branch-on-count vp<[[IV_NEXT_EXIT]]>, vp<[[VTC]]> |
| 46 | +; IF-EVL-NEXT: No successors |
| 47 | +; IF-EVL-NEXT: } |
| 48 | +; IF-EVL-NEXT: Successor(s): middle.block |
| 49 | +; IF-EVL-EMPTY: |
| 50 | +; IF-EVL: middle.block: |
| 51 | +; IF-EVL-NEXT: EMIT vp<[[RESUME_EXTRACT:%.+]]> = extract-from-end ir<[[LD]]>, ir<1> |
| 52 | +; IF-EVL-NEXT: EMIT branch-on-cond ir<true> |
| 53 | +; IF-EVL-NEXT: Successor(s): ir-bb<for.end>, scalar.ph |
| 54 | + |
| 55 | +entry: |
| 56 | + br label %for.body |
| 57 | + |
| 58 | +for.body: |
| 59 | + %indvars = phi i64 [ 0, %entry ], [ %indvars.next, %for.body ] |
| 60 | + %for1 = phi i32 [ 33, %entry ], [ %0, %for.body ] |
| 61 | + %arrayidx = getelementptr inbounds nuw i32, ptr %A, i64 %indvars |
| 62 | + %0 = load i32, ptr %arrayidx, align 4 |
| 63 | + %add = add nsw i32 %for1, %0 |
| 64 | + %arrayidx2 = getelementptr inbounds nuw i32, ptr %B, i64 %indvars |
| 65 | + store i32 %add, ptr %arrayidx2, align 4 |
| 66 | + %indvars.next = add nuw nsw i64 %indvars, 1 |
| 67 | + %exitcond.not = icmp eq i64 %indvars.next, %TC |
| 68 | + br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !0 |
| 69 | + |
| 70 | +for.end: |
| 71 | + ret void |
| 72 | +} |
| 73 | + |
| 74 | +!0 = distinct !{!0, !1} |
| 75 | +!1 = !{!"llvm.loop.vectorize.enable", i1 true} |
0 commit comments