| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | |
| ; RUN: opt < %s -passes=loop-vectorize -mtriple riscv64 -mattr=+v -S --riscv-v-register-bit-width-lmul=1 | FileCheck %s -check-prefix=LMUL1 | |
| ; RUN: opt < %s -passes=loop-vectorize -mtriple riscv64 -mattr=+v -S --riscv-v-register-bit-width-lmul=2 | FileCheck %s -check-prefix=LMUL2 | |
| ; RUN: opt < %s -passes=loop-vectorize -mtriple riscv64 -mattr=+v -S --riscv-v-register-bit-width-lmul=4 | FileCheck %s -check-prefix=LMUL4 | |
| ; RUN: opt < %s -passes=loop-vectorize -mtriple riscv64 -mattr=+v -S --riscv-v-register-bit-width-lmul=8 | FileCheck %s -check-prefix=LMUL8 | |
| ; RUN: opt < %s -passes=loop-vectorize -mtriple riscv64 -mattr=+v -S | FileCheck %s -check-prefix=LMUL2 | |
| define void @load_store(ptr %p) vscale_range(2, 1024) { | |
| ; LMUL1-LABEL: @load_store( | |
| ; LMUL1-NEXT: entry: | |
| ; LMUL1-NEXT: br label [[VECTOR_PH:%.*]] | |
| ; LMUL1: vector.ph: | |
| ; LMUL1-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64() | |
| ; LMUL1-NEXT: br label [[VECTOR_BODY:%.*]] | |
| ; LMUL1: vector.body: | |
| ; LMUL1-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] | |
| ; LMUL1-NEXT: [[TMP3:%.*]] = getelementptr inbounds i64, ptr [[P:%.*]], i64 [[INDEX]] | |
| ; LMUL1-NEXT: [[WIDE_LOAD:%.*]] = load <vscale x 1 x i64>, ptr [[TMP3]], align 8 | |
| ; LMUL1-NEXT: [[TMP5:%.*]] = add <vscale x 1 x i64> [[WIDE_LOAD]], splat (i64 1) | |
| ; LMUL1-NEXT: store <vscale x 1 x i64> [[TMP5]], ptr [[TMP3]], align 8 | |
| ; LMUL1-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP0]] | |
| ; LMUL1-NEXT: [[TMP4:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 | |
| ; LMUL1-NEXT: br i1 [[TMP4]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]] | |
| ; LMUL1: middle.block: | |
| ; LMUL1-NEXT: br label [[FOR_BODY:%.*]] | |
| ; LMUL1: for.end: | |
| ; LMUL1-NEXT: ret void | |
| ; | |
| ; LMUL2-LABEL: @load_store( | |
| ; LMUL2-NEXT: entry: | |
| ; LMUL2-NEXT: br label [[VECTOR_PH:%.*]] | |
| ; LMUL2: vector.ph: | |
| ; LMUL2-NEXT: br label [[VECTOR_BODY:%.*]] | |
| ; LMUL2: vector.body: | |
| ; LMUL2-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] | |
| ; LMUL2-NEXT: [[AVL:%.*]] = phi i64 [ 1024, [[VECTOR_PH]] ], [ [[AVL_NEXT:%.*]], [[VECTOR_BODY]] ] | |
| ; LMUL2-NEXT: [[TMP6:%.*]] = call i32 @llvm.experimental.get.vector.length.i64(i64 [[AVL]], i32 2, i1 true) | |
| ; LMUL2-NEXT: [[TMP5:%.*]] = getelementptr inbounds i64, ptr [[P:%.*]], i64 [[INDEX]] | |
| ; LMUL2-NEXT: [[WIDE_LOAD:%.*]] = call <vscale x 2 x i64> @llvm.vp.load.nxv2i64.p0(ptr align 8 [[TMP5]], <vscale x 2 x i1> splat (i1 true), i32 [[TMP6]]) | |
| ; LMUL2-NEXT: [[TMP7:%.*]] = add <vscale x 2 x i64> [[WIDE_LOAD]], splat (i64 1) | |
| ; LMUL2-NEXT: call void @llvm.vp.store.nxv2i64.p0(<vscale x 2 x i64> [[TMP7]], ptr align 8 [[TMP5]], <vscale x 2 x i1> splat (i1 true), i32 [[TMP6]]) | |
| ; LMUL2-NEXT: [[TMP10:%.*]] = zext i32 [[TMP6]] to i64 | |
| ; LMUL2-NEXT: [[INDEX_NEXT]] = add nuw i64 [[TMP10]], [[INDEX]] | |
| ; LMUL2-NEXT: [[AVL_NEXT]] = sub nuw i64 [[AVL]], [[TMP10]] | |
| ; LMUL2-NEXT: [[TMP11:%.*]] = icmp eq i64 [[AVL_NEXT]], 0 | |
| ; LMUL2-NEXT: br i1 [[TMP11]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]] | |
| ; LMUL2: middle.block: | |
| ; LMUL2-NEXT: br label [[FOR_BODY:%.*]] | |
| ; LMUL2: for.end: | |
| ; LMUL2-NEXT: ret void | |
| ; | |
| ; LMUL4-LABEL: @load_store( | |
| ; LMUL4-NEXT: entry: | |
| ; LMUL4-NEXT: br label [[VECTOR_PH:%.*]] | |
| ; LMUL4: vector.ph: | |
| ; LMUL4-NEXT: br label [[VECTOR_BODY:%.*]] | |
| ; LMUL4: vector.body: | |
| ; LMUL4-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] | |
| ; LMUL4-NEXT: [[AVL:%.*]] = phi i64 [ 1024, [[VECTOR_PH]] ], [ [[AVL_NEXT:%.*]], [[VECTOR_BODY]] ] | |
| ; LMUL4-NEXT: [[TMP6:%.*]] = call i32 @llvm.experimental.get.vector.length.i64(i64 [[AVL]], i32 4, i1 true) | |
| ; LMUL4-NEXT: [[TMP5:%.*]] = getelementptr inbounds i64, ptr [[P:%.*]], i64 [[INDEX]] | |
| ; LMUL4-NEXT: [[WIDE_LOAD:%.*]] = call <vscale x 4 x i64> @llvm.vp.load.nxv4i64.p0(ptr align 8 [[TMP5]], <vscale x 4 x i1> splat (i1 true), i32 [[TMP6]]) | |
| ; LMUL4-NEXT: [[TMP7:%.*]] = add <vscale x 4 x i64> [[WIDE_LOAD]], splat (i64 1) | |
| ; LMUL4-NEXT: call void @llvm.vp.store.nxv4i64.p0(<vscale x 4 x i64> [[TMP7]], ptr align 8 [[TMP5]], <vscale x 4 x i1> splat (i1 true), i32 [[TMP6]]) | |
| ; LMUL4-NEXT: [[TMP10:%.*]] = zext i32 [[TMP6]] to i64 | |
| ; LMUL4-NEXT: [[INDEX_NEXT]] = add nuw i64 [[TMP10]], [[INDEX]] | |
| ; LMUL4-NEXT: [[AVL_NEXT]] = sub nuw i64 [[AVL]], [[TMP10]] | |
| ; LMUL4-NEXT: [[TMP11:%.*]] = icmp eq i64 [[AVL_NEXT]], 0 | |
| ; LMUL4-NEXT: br i1 [[TMP11]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]] | |
| ; LMUL4: middle.block: | |
| ; LMUL4-NEXT: br label [[FOR_BODY:%.*]] | |
| ; LMUL4: for.end: | |
| ; LMUL4-NEXT: ret void | |
| ; | |
| ; LMUL8-LABEL: @load_store( | |
| ; LMUL8-NEXT: entry: | |
| ; LMUL8-NEXT: br label [[VECTOR_PH:%.*]] | |
| ; LMUL8: vector.ph: | |
| ; LMUL8-NEXT: br label [[VECTOR_BODY:%.*]] | |
| ; LMUL8: vector.body: | |
| ; LMUL8-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] | |
| ; LMUL8-NEXT: [[AVL:%.*]] = phi i64 [ 1024, [[VECTOR_PH]] ], [ [[AVL_NEXT:%.*]], [[VECTOR_BODY]] ] | |
| ; LMUL8-NEXT: [[TMP6:%.*]] = call i32 @llvm.experimental.get.vector.length.i64(i64 [[AVL]], i32 8, i1 true) | |
| ; LMUL8-NEXT: [[TMP5:%.*]] = getelementptr inbounds i64, ptr [[P:%.*]], i64 [[INDEX]] | |
| ; LMUL8-NEXT: [[WIDE_LOAD:%.*]] = call <vscale x 8 x i64> @llvm.vp.load.nxv8i64.p0(ptr align 8 [[TMP5]], <vscale x 8 x i1> splat (i1 true), i32 [[TMP6]]) | |
| ; LMUL8-NEXT: [[TMP7:%.*]] = add <vscale x 8 x i64> [[WIDE_LOAD]], splat (i64 1) | |
| ; LMUL8-NEXT: call void @llvm.vp.store.nxv8i64.p0(<vscale x 8 x i64> [[TMP7]], ptr align 8 [[TMP5]], <vscale x 8 x i1> splat (i1 true), i32 [[TMP6]]) | |
| ; LMUL8-NEXT: [[TMP10:%.*]] = zext i32 [[TMP6]] to i64 | |
| ; LMUL8-NEXT: [[INDEX_NEXT]] = add nuw i64 [[TMP10]], [[INDEX]] | |
| ; LMUL8-NEXT: [[AVL_NEXT]] = sub nuw i64 [[AVL]], [[TMP10]] | |
| ; LMUL8-NEXT: [[TMP11:%.*]] = icmp eq i64 [[AVL_NEXT]], 0 | |
| ; LMUL8-NEXT: br i1 [[TMP11]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]] | |
| ; LMUL8: middle.block: | |
| ; LMUL8-NEXT: br label [[FOR_BODY:%.*]] | |
| ; LMUL8: for.end: | |
| ; LMUL8-NEXT: ret void | |
| ; | |
| entry: | |
| br label %for.body | |
| for.body: | |
| %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] | |
| %q = getelementptr inbounds i64, ptr %p, i64 %iv | |
| %v = load i64, ptr %q | |
| %w = add i64 %v, 1 | |
| store i64 %w, ptr %q | |
| %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 | |
| } |