| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | |
| ; RUN: opt < %s -passes=loop-vectorize -mtriple riscv64-linux-gnu -mattr=+v,+f -S 2>%t | FileCheck %s | |
| ; This is a collection of tests whose only purpose is to show changes in the | |
| ; default configuration. Please keep these tests minimal - if you're testing | |
| ; functionality of some specific configuration, please place that in a | |
| ; separate test file with a hard coded configuration (even if that | |
| ; configuration is the current default). | |
| target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" | |
| target triple = "riscv64" | |
| define void @vector_add(ptr noalias nocapture %a, i64 %v) vscale_range(2, 1024) { | |
| ; CHECK-LABEL: @vector_add( | |
| ; CHECK-NEXT: entry: | |
| ; CHECK-NEXT: br label [[VECTOR_PH:%.*]] | |
| ; CHECK: vector.ph: | |
| ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[V:%.*]], i64 0 | |
| ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[BROADCAST_SPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer | |
| ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] | |
| ; CHECK: vector.body: | |
| ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] | |
| ; CHECK-NEXT: [[AVL:%.*]] = phi i64 [ 1024, [[VECTOR_PH]] ], [ [[AVL_NEXT:%.*]], [[VECTOR_BODY]] ] | |
| ; CHECK-NEXT: [[TMP10:%.*]] = call i32 @llvm.experimental.get.vector.length.i64(i64 [[AVL]], i32 2, i1 true) | |
| ; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i64 [[INDEX]] | |
| ; CHECK-NEXT: [[WIDE_LOAD:%.*]] = call <vscale x 2 x i64> @llvm.vp.load.nxv2i64.p0(ptr align 8 [[TMP7]], <vscale x 2 x i1> splat (i1 true), i32 [[TMP10]]) | |
| ; CHECK-NEXT: [[TMP9:%.*]] = add <vscale x 2 x i64> [[WIDE_LOAD]], [[BROADCAST_SPLAT]] | |
| ; CHECK-NEXT: call void @llvm.vp.store.nxv2i64.p0(<vscale x 2 x i64> [[TMP9]], ptr align 8 [[TMP7]], <vscale x 2 x i1> splat (i1 true), i32 [[TMP10]]) | |
| ; CHECK-NEXT: [[TMP8:%.*]] = zext i32 [[TMP10]] to i64 | |
| ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[TMP8]], [[INDEX]] | |
| ; CHECK-NEXT: [[AVL_NEXT]] = sub nuw i64 [[AVL]], [[TMP8]] | |
| ; CHECK-NEXT: [[TMP6:%.*]] = icmp eq i64 [[AVL_NEXT]], 0 | |
| ; CHECK-NEXT: br i1 [[TMP6]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]] | |
| ; CHECK: middle.block: | |
| ; CHECK-NEXT: br label [[FOR_BODY:%.*]] | |
| ; CHECK: for.end: | |
| ; CHECK-NEXT: ret void | |
| ; | |
| entry: | |
| br label %for.body | |
| for.body: | |
| %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] | |
| %arrayidx = getelementptr inbounds i64, ptr %a, i64 %iv | |
| %elem = load i64, ptr %arrayidx | |
| %add = add i64 %elem, %v | |
| store i64 %add, ptr %arrayidx | |
| %iv.next = add nuw nsw i64 %iv, 1 | |
| %exitcond.not = icmp eq i64 %iv.next, 1024 | |
| br i1 %exitcond.not, label %for.end, label %for.body | |
| for.end: | |
| ret void | |
| } | |
| define i64 @vector_add_reduce(ptr noalias nocapture %a) vscale_range(2, 1024) { | |
| ; CHECK-LABEL: @vector_add_reduce( | |
| ; CHECK-NEXT: entry: | |
| ; CHECK-NEXT: br label [[VECTOR_PH:%.*]] | |
| ; CHECK: vector.ph: | |
| ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] | |
| ; CHECK: vector.body: | |
| ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] | |
| ; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <vscale x 2 x i64> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP9:%.*]], [[VECTOR_BODY]] ] | |
| ; CHECK-NEXT: [[AVL:%.*]] = phi i64 [ 1024, [[VECTOR_PH]] ], [ [[AVL_NEXT:%.*]], [[VECTOR_BODY]] ] | |
| ; CHECK-NEXT: [[TMP8:%.*]] = call i32 @llvm.experimental.get.vector.length.i64(i64 [[AVL]], i32 2, i1 true) | |
| ; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i64 [[INDEX]] | |
| ; CHECK-NEXT: [[VP_OP_LOAD:%.*]] = call <vscale x 2 x i64> @llvm.vp.load.nxv2i64.p0(ptr align 8 [[TMP7]], <vscale x 2 x i1> splat (i1 true), i32 [[TMP8]]) | |
| ; CHECK-NEXT: [[TMP12:%.*]] = add <vscale x 2 x i64> [[VEC_PHI]], [[VP_OP_LOAD]] | |
| ; CHECK-NEXT: [[TMP9]] = call <vscale x 2 x i64> @llvm.vp.merge.nxv2i64(<vscale x 2 x i1> splat (i1 true), <vscale x 2 x i64> [[TMP12]], <vscale x 2 x i64> [[VEC_PHI]], i32 [[TMP8]]) | |
| ; CHECK-NEXT: [[TMP13:%.*]] = zext i32 [[TMP8]] to i64 | |
| ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[TMP13]], [[INDEX]] | |
| ; CHECK-NEXT: [[AVL_NEXT]] = sub nuw i64 [[AVL]], [[TMP13]] | |
| ; CHECK-NEXT: [[TMP10:%.*]] = icmp eq i64 [[AVL_NEXT]], 0 | |
| ; CHECK-NEXT: br i1 [[TMP10]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]] | |
| ; CHECK: middle.block: | |
| ; CHECK-NEXT: [[TMP11:%.*]] = call i64 @llvm.vector.reduce.add.nxv2i64(<vscale x 2 x i64> [[TMP9]]) | |
| ; CHECK-NEXT: br label [[FOR_BODY:%.*]] | |
| ; CHECK: for.end: | |
| ; CHECK-NEXT: ret i64 [[TMP11]] | |
| ; | |
| entry: | |
| br label %for.body | |
| for.body: | |
| %iv = phi i64 [0, %entry], [%iv.next, %for.body] | |
| %sum = phi i64 [0, %entry], [%sum.next, %for.body] | |
| %arrayidx = getelementptr inbounds i64, ptr %a, i64 %iv | |
| %elem = load i64, ptr %arrayidx | |
| %iv.next = add nuw nsw i64 %iv, 1 | |
| %sum.next = add i64 %sum, %elem | |
| %exitcond.not = icmp eq i64 %iv.next, 1024 | |
| br i1 %exitcond.not, label %for.end, label %for.body | |
| for.end: | |
| ret i64 %sum.next | |
| } | |