76 lines · plain
1; REQUIRES: asserts2 3; RUN: opt -passes=loop-vectorize -debug-only=loop-vectorize \4; RUN: -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue \5; RUN: -mtriple=riscv64 -mattr=+v -riscv-v-vector-bits-max=128 -disable-output < %s 2>&1 | FileCheck --check-prefix=IF-EVL %s6 7define void @first_order_recurrence(ptr noalias %A, ptr noalias %B, i64 %TC) {8; IF-EVL: VPlan 'Initial VPlan for VF={1},UF>=1'9; IF-EVL-NOT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI10;11; IF-EVL: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {12; IF-EVL-NEXT: Live-in vp<[[VF:%[0-9]+]]> = VF13; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF14; IF-EVL-NEXT: Live-in vp<[[VTC:%[0-9]+]]> = vector-trip-count15; IF-EVL-NEXT: Live-in ir<%TC> = original trip-count16; IF-EVL-EMPTY:17; IF-EVL: ir-bb<entry>:18; IF-EVL-NEXT: Successor(s): scalar.ph, vector.ph19; IF-EVL-EMPTY:20; IF-EVL: vector.ph:21; IF-EVL-NEXT: EMIT-SCALAR vp<[[VF32:%[0-9]+]]> = trunc vp<[[VF]]> to i3222; IF-EVL-NEXT: Successor(s): vector loop23; IF-EVL-EMPTY:24; IF-EVL: <x1> vector loop: {25; IF-EVL-NEXT: vector.body:26; IF-EVL-NEXT: EMIT vp<[[IV:%[0-9]+]]> = CANONICAL-INDUCTION27; IF-EVL-NEXT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI vp<[[EVL_PHI:%[0-9]+]]> = phi ir<0>, vp<[[IV_NEXT:%.+]]>28; IF-EVL-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<[[FOR_PHI:%.+]]> = phi ir<33>, ir<[[LD:%.+]]>29; IF-EVL-NEXT: EMIT-SCALAR vp<[[AVL:%.+]]> = phi [ ir<%TC>, vector.ph ], [ vp<[[AVL_NEXT:%.+]]>, vector.body ]30; IF-EVL-NEXT: EMIT-SCALAR vp<[[PREV_EVL:%.+]]> = phi [ vp<[[VF32]]>, vector.ph ], [ vp<[[EVL:%.+]]>, vector.body ]31; IF-EVL-NEXT: EMIT-SCALAR vp<[[EVL]]> = EXPLICIT-VECTOR-LENGTH vp<[[AVL]]>32; IF-EVL-NEXT: vp<[[ST:%[0-9]+]]> = SCALAR-STEPS vp<[[EVL_PHI]]>, ir<1>33; IF-EVL-NEXT: CLONE ir<[[GEP1:%.+]]> = getelementptr inbounds nuw ir<%A>, vp<[[ST]]34; IF-EVL-NEXT: vp<[[PTR1:%[0-9]+]]> = vector-pointer inbounds nuw ir<[[GEP1]]>35; IF-EVL-NEXT: WIDEN ir<[[LD]]> = vp.load vp<[[PTR1]]>, vp<[[EVL]]>36; 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]]>)37; IF-EVL-NEXT: WIDEN ir<[[ADD:%.+]]> = add nsw vp<[[SPLICE]]>, ir<[[LD]]>38; IF-EVL-NEXT: CLONE ir<[[GEP2:%.+]]> = getelementptr inbounds nuw ir<%B>, vp<[[ST]]>39; IF-EVL-NEXT: vp<[[PTR2:%[0-9]+]]> = vector-pointer inbounds nuw ir<[[GEP2]]>40; IF-EVL-NEXT: WIDEN vp.store vp<[[PTR2]]>, ir<[[ADD]]>, vp<[[EVL]]>41; IF-EVL-NEXT: EMIT-SCALAR vp<[[CAST:%[0-9]+]]> = zext vp<[[EVL]]> to i6442; IF-EVL-NEXT: EMIT vp<[[IV_NEXT]]> = add vp<[[CAST]]>, vp<[[EVL_PHI]]>43; IF-EVL-NEXT: EMIT vp<[[AVL_NEXT]]> = sub nuw vp<[[AVL]]>, vp<[[CAST]]>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 successors47; IF-EVL-NEXT: }48; IF-EVL-NEXT: Successor(s): middle.block49; IF-EVL-EMPTY:50; IF-EVL: middle.block:51; IF-EVL-NEXT: Successor(s): ir-bb<for.end>52 53; IF-EVL: Cost of 0 for VF vscale x 4: FIRST-ORDER-RECURRENCE-PHI ir<[[FOR_PHI]]> = phi ir<33>, ir<[[LD]]>54; IF-EVL: Cost of 4 for VF vscale x 4: WIDEN-INTRINSIC vp<[[SPLICE]]> = call llvm.experimental.vp.splice(ir<[[FOR_PHI]]>, ir<[[LD]]>, ir<-1>, ir<true>, vp<[[PREV_EVL]]>, vp<[[EVL]]>)55entry:56 br label %for.body57 58for.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 %indvars62 %0 = load i32, ptr %arrayidx, align 463 %add = add nsw i32 %for1, %064 %arrayidx2 = getelementptr inbounds nuw i32, ptr %B, i64 %indvars65 store i32 %add, ptr %arrayidx2, align 466 %indvars.next = add nuw nsw i64 %indvars, 167 %exitcond.not = icmp eq i64 %indvars.next, %TC68 br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !069 70for.end:71 ret void72}73 74!0 = distinct !{!0, !1}75!1 = !{!"llvm.loop.vectorize.enable", i1 true}76