1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-vectorize \
3 ; RUN: -force-tail-folding-style=data-with-evl \
4 ; RUN: -prefer-predicate-over-epilogue=predicate-dont-vectorize \
5 ; RUN: -mtriple=riscv64 -mattr=+v -S < %s | FileCheck %s --check-prefix=IF-EVL
7 ; RUN: opt -passes=loop-vectorize \
8 ; RUN: -force-tail-folding-style=none \
9 ; RUN: -prefer-predicate-over-epilogue=predicate-dont-vectorize \
10 ; RUN: -mtriple=riscv64 -mattr=+v -S < %s | FileCheck %s --check-prefix=NO-VP
12 define void @gather_scatter(ptr noalias %in, ptr noalias %out, ptr noalias %index, i64 %n) {
13 ; IF-EVL-LABEL: @gather_scatter(
15 ; IF-EVL-NEXT: br label [[FOR_BODY:%.*]]
17 ; IF-EVL-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
18 ; IF-EVL-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds i32, ptr [[INDEX:%.*]], i64 [[INDVARS_IV]]
19 ; IF-EVL-NEXT: [[TMP0:%.*]] = load i64, ptr [[ARRAYIDX3]], align 8
20 ; IF-EVL-NEXT: [[ARRAYIDX5:%.*]] = getelementptr inbounds float, ptr [[IN:%.*]], i64 [[TMP0]]
21 ; IF-EVL-NEXT: [[TMP1:%.*]] = load float, ptr [[ARRAYIDX5]], align 4
22 ; IF-EVL-NEXT: [[ARRAYIDX7:%.*]] = getelementptr inbounds float, ptr [[OUT:%.*]], i64 [[TMP0]]
23 ; IF-EVL-NEXT: store float [[TMP1]], ptr [[ARRAYIDX7]], align 4
24 ; IF-EVL-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
25 ; IF-EVL-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N:%.*]]
26 ; IF-EVL-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_END:%.*]], label [[FOR_BODY]]
28 ; IF-EVL-NEXT: ret void
30 ; NO-VP-LABEL: @gather_scatter(
32 ; NO-VP-NEXT: br label [[FOR_BODY:%.*]]
34 ; NO-VP-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
35 ; NO-VP-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds i32, ptr [[INDEX:%.*]], i64 [[INDVARS_IV]]
36 ; NO-VP-NEXT: [[TMP0:%.*]] = load i64, ptr [[ARRAYIDX3]], align 8
37 ; NO-VP-NEXT: [[ARRAYIDX5:%.*]] = getelementptr inbounds float, ptr [[IN:%.*]], i64 [[TMP0]]
38 ; NO-VP-NEXT: [[TMP1:%.*]] = load float, ptr [[ARRAYIDX5]], align 4
39 ; NO-VP-NEXT: [[ARRAYIDX7:%.*]] = getelementptr inbounds float, ptr [[OUT:%.*]], i64 [[TMP0]]
40 ; NO-VP-NEXT: store float [[TMP1]], ptr [[ARRAYIDX7]], align 4
41 ; NO-VP-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
42 ; NO-VP-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N:%.*]]
43 ; NO-VP-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_END:%.*]], label [[FOR_BODY]]
45 ; NO-VP-NEXT: ret void
51 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
52 %arrayidx3 = getelementptr inbounds i32, ptr %index, i64 %indvars.iv
53 %0 = load i64, ptr %arrayidx3, align 8
54 %arrayidx5 = getelementptr inbounds float, ptr %in, i64 %0
55 %1 = load float, ptr %arrayidx5, align 4
56 %arrayidx7 = getelementptr inbounds float, ptr %out, i64 %0
57 store float %1, ptr %arrayidx7, align 4
58 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
59 %exitcond.not = icmp eq i64 %indvars.iv.next, %n
60 br i1 %exitcond.not, label %for.end, label %for.body