1; RUN: opt %s -S -riscv-gather-scatter-lowering -mtriple=riscv64 -mattr=+m,+v -riscv-v-vector-bits-min=256 | FileCheck %s 2; RUN: llc < %s -mtriple=riscv64 -mattr=+m,+v -riscv-v-vector-bits-min=256 | FileCheck %s --check-prefix=CHECK-ASM 3 4%struct.foo = type { i32, i32, i32, i32 } 5 6; void gather(signed char * __restrict A, signed char * __restrict B) { 7; for (int i = 0; i != 1024; ++i) 8; A[i] += B[i * 5]; 9; } 10define void @gather(i8* noalias nocapture %A, i8* noalias nocapture readonly %B) { 11; CHECK-LABEL: @gather( 12; CHECK-NEXT: entry: 13; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 14; CHECK: vector.body: 15; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 16; CHECK-NEXT: [[VEC_IND_SCALAR:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR:%.*]], [[VECTOR_BODY]] ] 17; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i8, i8* [[B:%.*]], i64 [[VEC_IND_SCALAR]] 18; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <32 x i8> @llvm.riscv.masked.strided.load.v32i8.p0i8.i64(<32 x i8> undef, i8* [[TMP0]], i64 5, <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 19; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, i8* [[A:%.*]], i64 [[INDEX]] 20; CHECK-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP1]] to <32 x i8>* 21; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <32 x i8>, <32 x i8>* [[TMP2]], align 1 22; CHECK-NEXT: [[TMP3:%.*]] = add <32 x i8> [[WIDE_LOAD]], [[WIDE_MASKED_GATHER]] 23; CHECK-NEXT: [[TMP4:%.*]] = bitcast i8* [[TMP1]] to <32 x i8>* 24; CHECK-NEXT: store <32 x i8> [[TMP3]], <32 x i8>* [[TMP4]], align 1 25; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 32 26; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR]] = add i64 [[VEC_IND_SCALAR]], 160 27; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 28; CHECK-NEXT: br i1 [[TMP5]], label [[FOR_COND_CLEANUP:%.*]], label [[VECTOR_BODY]] 29; CHECK: for.cond.cleanup: 30; CHECK-NEXT: ret void 31; 32; CHECK-ASM-LABEL: gather: 33; CHECK-ASM: # %bb.0: # %entry 34; CHECK-ASM-NEXT: li a2, 0 35; CHECK-ASM-NEXT: li a3, 32 36; CHECK-ASM-NEXT: li a4, 5 37; CHECK-ASM-NEXT: li a5, 1024 38; CHECK-ASM-NEXT: .LBB0_1: # %vector.body 39; CHECK-ASM-NEXT: # =>This Inner Loop Header: Depth=1 40; CHECK-ASM-NEXT: vsetvli zero, a3, e8, m1, ta, mu 41; CHECK-ASM-NEXT: vlse8.v v8, (a1), a4 42; CHECK-ASM-NEXT: add a6, a0, a2 43; CHECK-ASM-NEXT: vle8.v v9, (a6) 44; CHECK-ASM-NEXT: vadd.vv v8, v9, v8 45; CHECK-ASM-NEXT: vse8.v v8, (a6) 46; CHECK-ASM-NEXT: addi a2, a2, 32 47; CHECK-ASM-NEXT: addi a1, a1, 160 48; CHECK-ASM-NEXT: bne a2, a5, .LBB0_1 49; CHECK-ASM-NEXT: # %bb.2: # %for.cond.cleanup 50; CHECK-ASM-NEXT: ret 51entry: 52 br label %vector.body 53 54vector.body: ; preds = %vector.body, %entry 55 %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ] 56 %vec.ind = phi <32 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16, i64 17, i64 18, i64 19, i64 20, i64 21, i64 22, i64 23, i64 24, i64 25, i64 26, i64 27, i64 28, i64 29, i64 30, i64 31>, %entry ], [ %vec.ind.next, %vector.body ] 57 %0 = mul nuw nsw <32 x i64> %vec.ind, <i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5> 58 %1 = getelementptr inbounds i8, i8* %B, <32 x i64> %0 59 %wide.masked.gather = call <32 x i8> @llvm.masked.gather.v32i8.v32p0i8(<32 x i8*> %1, i32 1, <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <32 x i8> undef) 60 %2 = getelementptr inbounds i8, i8* %A, i64 %index 61 %3 = bitcast i8* %2 to <32 x i8>* 62 %wide.load = load <32 x i8>, <32 x i8>* %3, align 1 63 %4 = add <32 x i8> %wide.load, %wide.masked.gather 64 %5 = bitcast i8* %2 to <32 x i8>* 65 store <32 x i8> %4, <32 x i8>* %5, align 1 66 %index.next = add nuw i64 %index, 32 67 %vec.ind.next = add <32 x i64> %vec.ind, <i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32> 68 %6 = icmp eq i64 %index.next, 1024 69 br i1 %6, label %for.cond.cleanup, label %vector.body 70 71for.cond.cleanup: ; preds = %vector.body 72 ret void 73} 74 75define void @gather_masked(i8* noalias nocapture %A, i8* noalias nocapture readonly %B, <32 x i8> %maskedoff) { 76; CHECK-LABEL: @gather_masked( 77; CHECK-NEXT: entry: 78; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 79; CHECK: vector.body: 80; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 81; CHECK-NEXT: [[VEC_IND_SCALAR:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR:%.*]], [[VECTOR_BODY]] ] 82; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i8, i8* [[B:%.*]], i64 [[VEC_IND_SCALAR]] 83; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <32 x i8> @llvm.riscv.masked.strided.load.v32i8.p0i8.i64(<32 x i8> [[MASKEDOFF:%.*]], i8* [[TMP0]], i64 5, <32 x i1> <i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false, i1 true, i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 true, i1 true, i1 true, i1 true>) 84; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, i8* [[A:%.*]], i64 [[INDEX]] 85; CHECK-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP1]] to <32 x i8>* 86; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <32 x i8>, <32 x i8>* [[TMP2]], align 1 87; CHECK-NEXT: [[TMP3:%.*]] = add <32 x i8> [[WIDE_LOAD]], [[WIDE_MASKED_GATHER]] 88; CHECK-NEXT: [[TMP4:%.*]] = bitcast i8* [[TMP1]] to <32 x i8>* 89; CHECK-NEXT: store <32 x i8> [[TMP3]], <32 x i8>* [[TMP4]], align 1 90; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 32 91; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR]] = add i64 [[VEC_IND_SCALAR]], 160 92; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 93; CHECK-NEXT: br i1 [[TMP5]], label [[FOR_COND_CLEANUP:%.*]], label [[VECTOR_BODY]] 94; CHECK: for.cond.cleanup: 95; CHECK-NEXT: ret void 96; 97; CHECK-ASM-LABEL: gather_masked: 98; CHECK-ASM: # %bb.0: # %entry 99; CHECK-ASM-NEXT: li a2, 0 100; CHECK-ASM-NEXT: lui a3, 983765 101; CHECK-ASM-NEXT: addiw a3, a3, 873 102; CHECK-ASM-NEXT: vsetivli zero, 1, e32, mf2, ta, mu 103; CHECK-ASM-NEXT: vmv.s.x v0, a3 104; CHECK-ASM-NEXT: li a3, 32 105; CHECK-ASM-NEXT: li a4, 5 106; CHECK-ASM-NEXT: li a5, 1024 107; CHECK-ASM-NEXT: .LBB1_1: # %vector.body 108; CHECK-ASM-NEXT: # =>This Inner Loop Header: Depth=1 109; CHECK-ASM-NEXT: vsetvli zero, a3, e8, m1, ta, mu 110; CHECK-ASM-NEXT: vmv1r.v v9, v8 111; CHECK-ASM-NEXT: vlse8.v v9, (a1), a4, v0.t 112; CHECK-ASM-NEXT: add a6, a0, a2 113; CHECK-ASM-NEXT: vle8.v v10, (a6) 114; CHECK-ASM-NEXT: vadd.vv v9, v10, v9 115; CHECK-ASM-NEXT: vse8.v v9, (a6) 116; CHECK-ASM-NEXT: addi a2, a2, 32 117; CHECK-ASM-NEXT: addi a1, a1, 160 118; CHECK-ASM-NEXT: bne a2, a5, .LBB1_1 119; CHECK-ASM-NEXT: # %bb.2: # %for.cond.cleanup 120; CHECK-ASM-NEXT: ret 121entry: 122 br label %vector.body 123 124vector.body: ; preds = %vector.body, %entry 125 %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ] 126 %vec.ind = phi <32 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16, i64 17, i64 18, i64 19, i64 20, i64 21, i64 22, i64 23, i64 24, i64 25, i64 26, i64 27, i64 28, i64 29, i64 30, i64 31>, %entry ], [ %vec.ind.next, %vector.body ] 127 %0 = mul nuw nsw <32 x i64> %vec.ind, <i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5> 128 %1 = getelementptr inbounds i8, i8* %B, <32 x i64> %0 129 %wide.masked.gather = call <32 x i8> @llvm.masked.gather.v32i8.v32p0i8(<32 x i8*> %1, i32 1, <32 x i1> <i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false, i1 true, i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 true, i1 true, i1 true, i1 true>, <32 x i8> %maskedoff) 130 %2 = getelementptr inbounds i8, i8* %A, i64 %index 131 %3 = bitcast i8* %2 to <32 x i8>* 132 %wide.load = load <32 x i8>, <32 x i8>* %3, align 1 133 %4 = add <32 x i8> %wide.load, %wide.masked.gather 134 %5 = bitcast i8* %2 to <32 x i8>* 135 store <32 x i8> %4, <32 x i8>* %5, align 1 136 %index.next = add nuw i64 %index, 32 137 %vec.ind.next = add <32 x i64> %vec.ind, <i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32> 138 %6 = icmp eq i64 %index.next, 1024 139 br i1 %6, label %for.cond.cleanup, label %vector.body 140 141for.cond.cleanup: ; preds = %vector.body 142 ret void 143} 144 145define void @gather_negative_stride(i8* noalias nocapture %A, i8* noalias nocapture readonly %B) { 146; CHECK-LABEL: @gather_negative_stride( 147; CHECK-NEXT: entry: 148; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 149; CHECK: vector.body: 150; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 151; CHECK-NEXT: [[VEC_IND_SCALAR:%.*]] = phi i64 [ 155, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR:%.*]], [[VECTOR_BODY]] ] 152; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i8, i8* [[B:%.*]], i64 [[VEC_IND_SCALAR]] 153; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <32 x i8> @llvm.riscv.masked.strided.load.v32i8.p0i8.i64(<32 x i8> undef, i8* [[TMP0]], i64 -5, <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 154; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, i8* [[A:%.*]], i64 [[INDEX]] 155; CHECK-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP1]] to <32 x i8>* 156; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <32 x i8>, <32 x i8>* [[TMP2]], align 1 157; CHECK-NEXT: [[TMP3:%.*]] = add <32 x i8> [[WIDE_LOAD]], [[WIDE_MASKED_GATHER]] 158; CHECK-NEXT: [[TMP4:%.*]] = bitcast i8* [[TMP1]] to <32 x i8>* 159; CHECK-NEXT: store <32 x i8> [[TMP3]], <32 x i8>* [[TMP4]], align 1 160; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 32 161; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR]] = add i64 [[VEC_IND_SCALAR]], 160 162; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 163; CHECK-NEXT: br i1 [[TMP5]], label [[FOR_COND_CLEANUP:%.*]], label [[VECTOR_BODY]] 164; CHECK: for.cond.cleanup: 165; CHECK-NEXT: ret void 166; 167; CHECK-ASM-LABEL: gather_negative_stride: 168; CHECK-ASM: # %bb.0: # %entry 169; CHECK-ASM-NEXT: li a2, 0 170; CHECK-ASM-NEXT: addi a1, a1, 155 171; CHECK-ASM-NEXT: li a3, 32 172; CHECK-ASM-NEXT: li a4, -5 173; CHECK-ASM-NEXT: li a5, 1024 174; CHECK-ASM-NEXT: .LBB2_1: # %vector.body 175; CHECK-ASM-NEXT: # =>This Inner Loop Header: Depth=1 176; CHECK-ASM-NEXT: vsetvli zero, a3, e8, m1, ta, mu 177; CHECK-ASM-NEXT: vlse8.v v8, (a1), a4 178; CHECK-ASM-NEXT: add a6, a0, a2 179; CHECK-ASM-NEXT: vle8.v v9, (a6) 180; CHECK-ASM-NEXT: vadd.vv v8, v9, v8 181; CHECK-ASM-NEXT: vse8.v v8, (a6) 182; CHECK-ASM-NEXT: addi a2, a2, 32 183; CHECK-ASM-NEXT: addi a1, a1, 160 184; CHECK-ASM-NEXT: bne a2, a5, .LBB2_1 185; CHECK-ASM-NEXT: # %bb.2: # %for.cond.cleanup 186; CHECK-ASM-NEXT: ret 187entry: 188 br label %vector.body 189 190vector.body: ; preds = %vector.body, %entry 191 %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ] 192 %vec.ind = phi <32 x i64> [ <i64 31, i64 30, i64 29, i64 28, i64 27, i64 26, i64 25, i64 24, i64 23, i64 22, i64 21, i64 20, i64 19, i64 18, i64 17, i64 16, i64 15, i64 14, i64 13, i64 12, i64 11, i64 10, i64 9, i64 8, i64 7, i64 6, i64 5, i64 4, i64 3, i64 2, i64 1, i64 0>, %entry ], [ %vec.ind.next, %vector.body ] 193 %0 = mul nuw nsw <32 x i64> %vec.ind, <i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5> 194 %1 = getelementptr inbounds i8, i8* %B, <32 x i64> %0 195 %wide.masked.gather = call <32 x i8> @llvm.masked.gather.v32i8.v32p0i8(<32 x i8*> %1, i32 1, <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <32 x i8> undef) 196 %2 = getelementptr inbounds i8, i8* %A, i64 %index 197 %3 = bitcast i8* %2 to <32 x i8>* 198 %wide.load = load <32 x i8>, <32 x i8>* %3, align 1 199 %4 = add <32 x i8> %wide.load, %wide.masked.gather 200 %5 = bitcast i8* %2 to <32 x i8>* 201 store <32 x i8> %4, <32 x i8>* %5, align 1 202 %index.next = add nuw i64 %index, 32 203 %vec.ind.next = add <32 x i64> %vec.ind, <i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32> 204 %6 = icmp eq i64 %index.next, 1024 205 br i1 %6, label %for.cond.cleanup, label %vector.body 206 207for.cond.cleanup: ; preds = %vector.body 208 ret void 209} 210 211define void @gather_zero_stride(i8* noalias nocapture %A, i8* noalias nocapture readonly %B) { 212; CHECK-LABEL: @gather_zero_stride( 213; CHECK-NEXT: entry: 214; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 215; CHECK: vector.body: 216; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 217; CHECK-NEXT: [[VEC_IND_SCALAR:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR:%.*]], [[VECTOR_BODY]] ] 218; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i8, i8* [[B:%.*]], i64 [[VEC_IND_SCALAR]] 219; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <32 x i8> @llvm.riscv.masked.strided.load.v32i8.p0i8.i64(<32 x i8> undef, i8* [[TMP0]], i64 0, <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 220; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, i8* [[A:%.*]], i64 [[INDEX]] 221; CHECK-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP1]] to <32 x i8>* 222; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <32 x i8>, <32 x i8>* [[TMP2]], align 1 223; CHECK-NEXT: [[TMP3:%.*]] = add <32 x i8> [[WIDE_LOAD]], [[WIDE_MASKED_GATHER]] 224; CHECK-NEXT: [[TMP4:%.*]] = bitcast i8* [[TMP1]] to <32 x i8>* 225; CHECK-NEXT: store <32 x i8> [[TMP3]], <32 x i8>* [[TMP4]], align 1 226; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 32 227; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR]] = add i64 [[VEC_IND_SCALAR]], 160 228; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 229; CHECK-NEXT: br i1 [[TMP5]], label [[FOR_COND_CLEANUP:%.*]], label [[VECTOR_BODY]] 230; CHECK: for.cond.cleanup: 231; CHECK-NEXT: ret void 232; 233; CHECK-ASM-LABEL: gather_zero_stride: 234; CHECK-ASM: # %bb.0: # %entry 235; CHECK-ASM-NEXT: li a2, 0 236; CHECK-ASM-NEXT: li a3, 32 237; CHECK-ASM-NEXT: li a4, 1024 238; CHECK-ASM-NEXT: .LBB3_1: # %vector.body 239; CHECK-ASM-NEXT: # =>This Inner Loop Header: Depth=1 240; CHECK-ASM-NEXT: vsetvli zero, a3, e8, m1, ta, mu 241; CHECK-ASM-NEXT: vlse8.v v8, (a1), zero 242; CHECK-ASM-NEXT: add a5, a0, a2 243; CHECK-ASM-NEXT: vle8.v v9, (a5) 244; CHECK-ASM-NEXT: vadd.vv v8, v9, v8 245; CHECK-ASM-NEXT: vse8.v v8, (a5) 246; CHECK-ASM-NEXT: addi a2, a2, 32 247; CHECK-ASM-NEXT: addi a1, a1, 160 248; CHECK-ASM-NEXT: bne a2, a4, .LBB3_1 249; CHECK-ASM-NEXT: # %bb.2: # %for.cond.cleanup 250; CHECK-ASM-NEXT: ret 251entry: 252 br label %vector.body 253 254vector.body: ; preds = %vector.body, %entry 255 %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ] 256 %vec.ind = phi <32 x i64> [ zeroinitializer, %entry ], [ %vec.ind.next, %vector.body ] 257 %0 = mul nuw nsw <32 x i64> %vec.ind, <i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5> 258 %1 = getelementptr inbounds i8, i8* %B, <32 x i64> %0 259 %wide.masked.gather = call <32 x i8> @llvm.masked.gather.v32i8.v32p0i8(<32 x i8*> %1, i32 1, <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <32 x i8> undef) 260 %2 = getelementptr inbounds i8, i8* %A, i64 %index 261 %3 = bitcast i8* %2 to <32 x i8>* 262 %wide.load = load <32 x i8>, <32 x i8>* %3, align 1 263 %4 = add <32 x i8> %wide.load, %wide.masked.gather 264 %5 = bitcast i8* %2 to <32 x i8>* 265 store <32 x i8> %4, <32 x i8>* %5, align 1 266 %index.next = add nuw i64 %index, 32 267 %vec.ind.next = add <32 x i64> %vec.ind, <i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32> 268 %6 = icmp eq i64 %index.next, 1024 269 br i1 %6, label %for.cond.cleanup, label %vector.body 270 271for.cond.cleanup: ; preds = %vector.body 272 ret void 273} 274 275;void scatter(signed char * __restrict A, signed char * __restrict B) { 276; for (int i = 0; i < 1024; ++i) 277; A[i * 5] += B[i]; 278;} 279define void @scatter(i8* noalias nocapture %A, i8* noalias nocapture readonly %B) { 280; CHECK-LABEL: @scatter( 281; CHECK-NEXT: entry: 282; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 283; CHECK: vector.body: 284; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 285; CHECK-NEXT: [[VEC_IND_SCALAR:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR:%.*]], [[VECTOR_BODY]] ] 286; CHECK-NEXT: [[VEC_IND_SCALAR1:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR2:%.*]], [[VECTOR_BODY]] ] 287; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, i8* [[B:%.*]], i64 [[INDEX]] 288; CHECK-NEXT: [[TMP1:%.*]] = bitcast i8* [[TMP0]] to <32 x i8>* 289; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <32 x i8>, <32 x i8>* [[TMP1]], align 1 290; CHECK-NEXT: [[TMP2:%.*]] = getelementptr i8, i8* [[A:%.*]], i64 [[VEC_IND_SCALAR]] 291; CHECK-NEXT: [[TMP3:%.*]] = getelementptr i8, i8* [[A]], i64 [[VEC_IND_SCALAR1]] 292; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <32 x i8> @llvm.riscv.masked.strided.load.v32i8.p0i8.i64(<32 x i8> undef, i8* [[TMP2]], i64 5, <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 293; CHECK-NEXT: [[TMP4:%.*]] = add <32 x i8> [[WIDE_MASKED_GATHER]], [[WIDE_LOAD]] 294; CHECK-NEXT: call void @llvm.riscv.masked.strided.store.v32i8.p0i8.i64(<32 x i8> [[TMP4]], i8* [[TMP3]], i64 5, <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 295; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 32 296; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR]] = add i64 [[VEC_IND_SCALAR]], 160 297; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR2]] = add i64 [[VEC_IND_SCALAR1]], 160 298; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 299; CHECK-NEXT: br i1 [[TMP5]], label [[FOR_COND_CLEANUP:%.*]], label [[VECTOR_BODY]] 300; CHECK: for.cond.cleanup: 301; CHECK-NEXT: ret void 302; 303; CHECK-ASM-LABEL: scatter: 304; CHECK-ASM: # %bb.0: # %entry 305; CHECK-ASM-NEXT: li a2, 0 306; CHECK-ASM-NEXT: li a3, 32 307; CHECK-ASM-NEXT: li a4, 5 308; CHECK-ASM-NEXT: li a5, 1024 309; CHECK-ASM-NEXT: .LBB4_1: # %vector.body 310; CHECK-ASM-NEXT: # =>This Inner Loop Header: Depth=1 311; CHECK-ASM-NEXT: add a6, a1, a2 312; CHECK-ASM-NEXT: vsetvli zero, a3, e8, m1, ta, mu 313; CHECK-ASM-NEXT: vle8.v v8, (a6) 314; CHECK-ASM-NEXT: vlse8.v v9, (a0), a4 315; CHECK-ASM-NEXT: vadd.vv v8, v9, v8 316; CHECK-ASM-NEXT: vsse8.v v8, (a0), a4 317; CHECK-ASM-NEXT: addi a2, a2, 32 318; CHECK-ASM-NEXT: addi a0, a0, 160 319; CHECK-ASM-NEXT: bne a2, a5, .LBB4_1 320; CHECK-ASM-NEXT: # %bb.2: # %for.cond.cleanup 321; CHECK-ASM-NEXT: ret 322entry: 323 br label %vector.body 324 325vector.body: ; preds = %vector.body, %entry 326 %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ] 327 %vec.ind = phi <32 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16, i64 17, i64 18, i64 19, i64 20, i64 21, i64 22, i64 23, i64 24, i64 25, i64 26, i64 27, i64 28, i64 29, i64 30, i64 31>, %entry ], [ %vec.ind.next, %vector.body ] 328 %0 = getelementptr inbounds i8, i8* %B, i64 %index 329 %1 = bitcast i8* %0 to <32 x i8>* 330 %wide.load = load <32 x i8>, <32 x i8>* %1, align 1 331 %2 = mul nuw nsw <32 x i64> %vec.ind, <i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5> 332 %3 = getelementptr inbounds i8, i8* %A, <32 x i64> %2 333 %wide.masked.gather = call <32 x i8> @llvm.masked.gather.v32i8.v32p0i8(<32 x i8*> %3, i32 1, <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <32 x i8> undef) 334 %4 = add <32 x i8> %wide.masked.gather, %wide.load 335 call void @llvm.masked.scatter.v32i8.v32p0i8(<32 x i8> %4, <32 x i8*> %3, i32 1, <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 336 %index.next = add nuw i64 %index, 32 337 %vec.ind.next = add <32 x i64> %vec.ind, <i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32> 338 %5 = icmp eq i64 %index.next, 1024 339 br i1 %5, label %for.cond.cleanup, label %vector.body 340 341for.cond.cleanup: ; preds = %vector.body 342 ret void 343} 344 345define void @scatter_masked(i8* noalias nocapture %A, i8* noalias nocapture readonly %B, <32 x i8> %maskedoff) { 346; CHECK-LABEL: @scatter_masked( 347; CHECK-NEXT: entry: 348; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 349; CHECK: vector.body: 350; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 351; CHECK-NEXT: [[VEC_IND_SCALAR:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR:%.*]], [[VECTOR_BODY]] ] 352; CHECK-NEXT: [[VEC_IND_SCALAR1:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR2:%.*]], [[VECTOR_BODY]] ] 353; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, i8* [[B:%.*]], i64 [[INDEX]] 354; CHECK-NEXT: [[TMP1:%.*]] = bitcast i8* [[TMP0]] to <32 x i8>* 355; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <32 x i8>, <32 x i8>* [[TMP1]], align 1 356; CHECK-NEXT: [[TMP2:%.*]] = getelementptr i8, i8* [[A:%.*]], i64 [[VEC_IND_SCALAR]] 357; CHECK-NEXT: [[TMP3:%.*]] = getelementptr i8, i8* [[A]], i64 [[VEC_IND_SCALAR1]] 358; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <32 x i8> @llvm.riscv.masked.strided.load.v32i8.p0i8.i64(<32 x i8> [[MASKEDOFF:%.*]], i8* [[TMP2]], i64 5, <32 x i1> <i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false, i1 true, i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 true, i1 true, i1 true, i1 true>) 359; CHECK-NEXT: [[TMP4:%.*]] = add <32 x i8> [[WIDE_MASKED_GATHER]], [[WIDE_LOAD]] 360; CHECK-NEXT: call void @llvm.riscv.masked.strided.store.v32i8.p0i8.i64(<32 x i8> [[TMP4]], i8* [[TMP3]], i64 5, <32 x i1> <i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false, i1 true, i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 true, i1 true, i1 true, i1 true>) 361; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 32 362; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR]] = add i64 [[VEC_IND_SCALAR]], 160 363; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR2]] = add i64 [[VEC_IND_SCALAR1]], 160 364; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 365; CHECK-NEXT: br i1 [[TMP5]], label [[FOR_COND_CLEANUP:%.*]], label [[VECTOR_BODY]] 366; CHECK: for.cond.cleanup: 367; CHECK-NEXT: ret void 368; 369; CHECK-ASM-LABEL: scatter_masked: 370; CHECK-ASM: # %bb.0: # %entry 371; CHECK-ASM-NEXT: li a2, 0 372; CHECK-ASM-NEXT: li a3, 32 373; CHECK-ASM-NEXT: lui a4, 983765 374; CHECK-ASM-NEXT: addiw a4, a4, 873 375; CHECK-ASM-NEXT: vsetivli zero, 1, e32, mf2, ta, mu 376; CHECK-ASM-NEXT: vmv.s.x v0, a4 377; CHECK-ASM-NEXT: li a4, 5 378; CHECK-ASM-NEXT: li a5, 1024 379; CHECK-ASM-NEXT: .LBB5_1: # %vector.body 380; CHECK-ASM-NEXT: # =>This Inner Loop Header: Depth=1 381; CHECK-ASM-NEXT: add a6, a1, a2 382; CHECK-ASM-NEXT: vsetvli zero, a3, e8, m1, ta, mu 383; CHECK-ASM-NEXT: vle8.v v9, (a6) 384; CHECK-ASM-NEXT: vmv1r.v v10, v8 385; CHECK-ASM-NEXT: vlse8.v v10, (a0), a4, v0.t 386; CHECK-ASM-NEXT: vadd.vv v9, v10, v9 387; CHECK-ASM-NEXT: vsse8.v v9, (a0), a4, v0.t 388; CHECK-ASM-NEXT: addi a2, a2, 32 389; CHECK-ASM-NEXT: addi a0, a0, 160 390; CHECK-ASM-NEXT: bne a2, a5, .LBB5_1 391; CHECK-ASM-NEXT: # %bb.2: # %for.cond.cleanup 392; CHECK-ASM-NEXT: ret 393entry: 394 br label %vector.body 395 396vector.body: ; preds = %vector.body, %entry 397 %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ] 398 %vec.ind = phi <32 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16, i64 17, i64 18, i64 19, i64 20, i64 21, i64 22, i64 23, i64 24, i64 25, i64 26, i64 27, i64 28, i64 29, i64 30, i64 31>, %entry ], [ %vec.ind.next, %vector.body ] 399 %0 = getelementptr inbounds i8, i8* %B, i64 %index 400 %1 = bitcast i8* %0 to <32 x i8>* 401 %wide.load = load <32 x i8>, <32 x i8>* %1, align 1 402 %2 = mul nuw nsw <32 x i64> %vec.ind, <i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5> 403 %3 = getelementptr inbounds i8, i8* %A, <32 x i64> %2 404 %wide.masked.gather = call <32 x i8> @llvm.masked.gather.v32i8.v32p0i8(<32 x i8*> %3, i32 1, <32 x i1> <i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false, i1 true, i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 true, i1 true, i1 true, i1 true>, <32 x i8> %maskedoff) 405 %4 = add <32 x i8> %wide.masked.gather, %wide.load 406 call void @llvm.masked.scatter.v32i8.v32p0i8(<32 x i8> %4, <32 x i8*> %3, i32 1, <32 x i1> <i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false, i1 true, i1 true, i1 false, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 true, i1 false, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 true, i1 true, i1 true, i1 true>) 407 %index.next = add nuw i64 %index, 32 408 %vec.ind.next = add <32 x i64> %vec.ind, <i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32> 409 %5 = icmp eq i64 %index.next, 1024 410 br i1 %5, label %for.cond.cleanup, label %vector.body 411 412for.cond.cleanup: ; preds = %vector.body 413 ret void 414} 415 416; void gather_pow2(signed char * __restrict A, signed char * __restrict B) { 417; for (int i = 0; i != 1024; ++i) 418; A[i] += B[i * 4]; 419; } 420define void @gather_pow2(i32* noalias nocapture %A, i32* noalias nocapture readonly %B) { 421; CHECK-LABEL: @gather_pow2( 422; CHECK-NEXT: entry: 423; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 424; CHECK: vector.body: 425; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 426; CHECK-NEXT: [[VEC_IND_SCALAR:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR:%.*]], [[VECTOR_BODY]] ] 427; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i32, i32* [[B:%.*]], i64 [[VEC_IND_SCALAR]] 428; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <8 x i32> @llvm.riscv.masked.strided.load.v8i32.p0i32.i64(<8 x i32> undef, i32* [[TMP0]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 429; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i64 [[INDEX]] 430; CHECK-NEXT: [[TMP2:%.*]] = bitcast i32* [[TMP1]] to <8 x i32>* 431; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <8 x i32>, <8 x i32>* [[TMP2]], align 1 432; CHECK-NEXT: [[TMP3:%.*]] = add <8 x i32> [[WIDE_LOAD]], [[WIDE_MASKED_GATHER]] 433; CHECK-NEXT: [[TMP4:%.*]] = bitcast i32* [[TMP1]] to <8 x i32>* 434; CHECK-NEXT: store <8 x i32> [[TMP3]], <8 x i32>* [[TMP4]], align 1 435; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 8 436; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR]] = add i64 [[VEC_IND_SCALAR]], 32 437; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 438; CHECK-NEXT: br i1 [[TMP5]], label [[FOR_COND_CLEANUP:%.*]], label [[VECTOR_BODY]] 439; CHECK: for.cond.cleanup: 440; CHECK-NEXT: ret void 441; 442; CHECK-ASM-LABEL: gather_pow2: 443; CHECK-ASM: # %bb.0: # %entry 444; CHECK-ASM-NEXT: li a2, 1024 445; CHECK-ASM-NEXT: li a3, 16 446; CHECK-ASM-NEXT: li a4, 32 447; CHECK-ASM-NEXT: .LBB6_1: # %vector.body 448; CHECK-ASM-NEXT: # =>This Inner Loop Header: Depth=1 449; CHECK-ASM-NEXT: vsetivli zero, 8, e32, m1, ta, mu 450; CHECK-ASM-NEXT: vlse32.v v8, (a1), a3 451; CHECK-ASM-NEXT: vsetvli zero, a4, e8, m1, ta, mu 452; CHECK-ASM-NEXT: vle8.v v9, (a0) 453; CHECK-ASM-NEXT: vsetivli zero, 8, e32, m1, ta, mu 454; CHECK-ASM-NEXT: vadd.vv v8, v9, v8 455; CHECK-ASM-NEXT: vsetvli zero, a4, e8, m1, ta, mu 456; CHECK-ASM-NEXT: vse8.v v8, (a0) 457; CHECK-ASM-NEXT: addi a2, a2, -8 458; CHECK-ASM-NEXT: addi a0, a0, 32 459; CHECK-ASM-NEXT: addi a1, a1, 128 460; CHECK-ASM-NEXT: bnez a2, .LBB6_1 461; CHECK-ASM-NEXT: # %bb.2: # %for.cond.cleanup 462; CHECK-ASM-NEXT: ret 463entry: 464 br label %vector.body 465 466vector.body: ; preds = %vector.body, %entry 467 %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ] 468 %vec.ind = phi <8 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7>, %entry ], [ %vec.ind.next, %vector.body ] 469 %0 = shl nsw <8 x i64> %vec.ind, <i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2> 470 %1 = getelementptr inbounds i32, i32* %B, <8 x i64> %0 471 %wide.masked.gather = call <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*> %1, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef) 472 %2 = getelementptr inbounds i32, i32* %A, i64 %index 473 %3 = bitcast i32* %2 to <8 x i32>* 474 %wide.load = load <8 x i32>, <8 x i32>* %3, align 1 475 %4 = add <8 x i32> %wide.load, %wide.masked.gather 476 %5 = bitcast i32* %2 to <8 x i32>* 477 store <8 x i32> %4, <8 x i32>* %5, align 1 478 %index.next = add nuw i64 %index, 8 479 %vec.ind.next = add <8 x i64> %vec.ind, <i64 8, i64 8, i64 8, i64 8, i64 8, i64 8, i64 8, i64 8> 480 %6 = icmp eq i64 %index.next, 1024 481 br i1 %6, label %for.cond.cleanup, label %vector.body 482 483for.cond.cleanup: ; preds = %vector.body 484 ret void 485} 486 487;void scatter_pow2(signed char * __restrict A, signed char * __restrict B) { 488; for (int i = 0; i < 1024; ++i) 489; A[i * 4] += B[i]; 490;} 491define void @scatter_pow2(i32* noalias nocapture %A, i32* noalias nocapture readonly %B) { 492; CHECK-LABEL: @scatter_pow2( 493; CHECK-NEXT: entry: 494; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 495; CHECK: vector.body: 496; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 497; CHECK-NEXT: [[VEC_IND_SCALAR:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR:%.*]], [[VECTOR_BODY]] ] 498; CHECK-NEXT: [[VEC_IND_SCALAR1:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR2:%.*]], [[VECTOR_BODY]] ] 499; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i32, i32* [[B:%.*]], i64 [[INDEX]] 500; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[TMP0]] to <8 x i32>* 501; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <8 x i32>, <8 x i32>* [[TMP1]], align 1 502; CHECK-NEXT: [[TMP2:%.*]] = getelementptr i32, i32* [[A:%.*]], i64 [[VEC_IND_SCALAR]] 503; CHECK-NEXT: [[TMP3:%.*]] = getelementptr i32, i32* [[A]], i64 [[VEC_IND_SCALAR1]] 504; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <8 x i32> @llvm.riscv.masked.strided.load.v8i32.p0i32.i64(<8 x i32> undef, i32* [[TMP2]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 505; CHECK-NEXT: [[TMP4:%.*]] = add <8 x i32> [[WIDE_MASKED_GATHER]], [[WIDE_LOAD]] 506; CHECK-NEXT: call void @llvm.riscv.masked.strided.store.v8i32.p0i32.i64(<8 x i32> [[TMP4]], i32* [[TMP3]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 507; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 8 508; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR]] = add i64 [[VEC_IND_SCALAR]], 32 509; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR2]] = add i64 [[VEC_IND_SCALAR1]], 32 510; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 511; CHECK-NEXT: br i1 [[TMP5]], label [[FOR_COND_CLEANUP:%.*]], label [[VECTOR_BODY]] 512; CHECK: for.cond.cleanup: 513; CHECK-NEXT: ret void 514; 515; CHECK-ASM-LABEL: scatter_pow2: 516; CHECK-ASM: # %bb.0: # %entry 517; CHECK-ASM-NEXT: li a2, 1024 518; CHECK-ASM-NEXT: li a3, 32 519; CHECK-ASM-NEXT: li a4, 16 520; CHECK-ASM-NEXT: .LBB7_1: # %vector.body 521; CHECK-ASM-NEXT: # =>This Inner Loop Header: Depth=1 522; CHECK-ASM-NEXT: vsetvli zero, a3, e8, m1, ta, mu 523; CHECK-ASM-NEXT: vle8.v v8, (a1) 524; CHECK-ASM-NEXT: vsetivli zero, 8, e32, m1, ta, mu 525; CHECK-ASM-NEXT: vlse32.v v9, (a0), a4 526; CHECK-ASM-NEXT: vadd.vv v8, v9, v8 527; CHECK-ASM-NEXT: vsse32.v v8, (a0), a4 528; CHECK-ASM-NEXT: addi a2, a2, -8 529; CHECK-ASM-NEXT: addi a1, a1, 32 530; CHECK-ASM-NEXT: addi a0, a0, 128 531; CHECK-ASM-NEXT: bnez a2, .LBB7_1 532; CHECK-ASM-NEXT: # %bb.2: # %for.cond.cleanup 533; CHECK-ASM-NEXT: ret 534entry: 535 br label %vector.body 536 537vector.body: ; preds = %vector.body, %entry 538 %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ] 539 %vec.ind = phi <8 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7>, %entry ], [ %vec.ind.next, %vector.body ] 540 %0 = getelementptr inbounds i32, i32* %B, i64 %index 541 %1 = bitcast i32* %0 to <8 x i32>* 542 %wide.load = load <8 x i32>, <8 x i32>* %1, align 1 543 %2 = shl nuw nsw <8 x i64> %vec.ind, <i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2> 544 %3 = getelementptr inbounds i32, i32* %A, <8 x i64> %2 545 %wide.masked.gather = call <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*> %3, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef) 546 %4 = add <8 x i32> %wide.masked.gather, %wide.load 547 call void @llvm.masked.scatter.v8i32.v8p0i32(<8 x i32> %4, <8 x i32*> %3, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 548 %index.next = add nuw i64 %index, 8 549 %vec.ind.next = add <8 x i64> %vec.ind, <i64 8, i64 8, i64 8, i64 8, i64 8, i64 8, i64 8, i64 8> 550 %5 = icmp eq i64 %index.next, 1024 551 br i1 %5, label %for.cond.cleanup, label %vector.body 552 553for.cond.cleanup: ; preds = %vector.body 554 ret void 555} 556 557;struct foo { 558; int a, b, c, d; 559;}; 560; 561;void struct_gather(int * __restrict A, struct foo * __restrict B) { 562; for (int i = 0; i < 1024; ++i) 563; A[i] += B[i].b; 564;} 565define void @struct_gather(i32* noalias nocapture %A, %struct.foo* noalias nocapture readonly %B) { 566; CHECK-LABEL: @struct_gather( 567; CHECK-NEXT: entry: 568; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 569; CHECK: vector.body: 570; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 571; CHECK-NEXT: [[VEC_IND_SCALAR:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR:%.*]], [[VECTOR_BODY]] ] 572; CHECK-NEXT: [[VEC_IND_SCALAR1:%.*]] = phi i64 [ 8, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR2:%.*]], [[VECTOR_BODY]] ] 573; CHECK-NEXT: [[TMP0:%.*]] = getelementptr [[STRUCT_FOO:%.*]], %struct.foo* [[B:%.*]], i64 [[VEC_IND_SCALAR]], i32 1 574; CHECK-NEXT: [[TMP1:%.*]] = getelementptr [[STRUCT_FOO]], %struct.foo* [[B]], i64 [[VEC_IND_SCALAR1]], i32 1 575; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <8 x i32> @llvm.riscv.masked.strided.load.v8i32.p0i32.i64(<8 x i32> undef, i32* [[TMP0]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 576; CHECK-NEXT: [[WIDE_MASKED_GATHER9:%.*]] = call <8 x i32> @llvm.riscv.masked.strided.load.v8i32.p0i32.i64(<8 x i32> undef, i32* [[TMP1]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 577; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i64 [[INDEX]] 578; CHECK-NEXT: [[TMP3:%.*]] = bitcast i32* [[TMP2]] to <8 x i32>* 579; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <8 x i32>, <8 x i32>* [[TMP3]], align 4 580; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds i32, i32* [[TMP2]], i64 8 581; CHECK-NEXT: [[TMP5:%.*]] = bitcast i32* [[TMP4]] to <8 x i32>* 582; CHECK-NEXT: [[WIDE_LOAD10:%.*]] = load <8 x i32>, <8 x i32>* [[TMP5]], align 4 583; CHECK-NEXT: [[TMP6:%.*]] = add nsw <8 x i32> [[WIDE_LOAD]], [[WIDE_MASKED_GATHER]] 584; CHECK-NEXT: [[TMP7:%.*]] = add nsw <8 x i32> [[WIDE_LOAD10]], [[WIDE_MASKED_GATHER9]] 585; CHECK-NEXT: [[TMP8:%.*]] = bitcast i32* [[TMP2]] to <8 x i32>* 586; CHECK-NEXT: store <8 x i32> [[TMP6]], <8 x i32>* [[TMP8]], align 4 587; CHECK-NEXT: [[TMP9:%.*]] = bitcast i32* [[TMP4]] to <8 x i32>* 588; CHECK-NEXT: store <8 x i32> [[TMP7]], <8 x i32>* [[TMP9]], align 4 589; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16 590; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR]] = add i64 [[VEC_IND_SCALAR]], 16 591; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR2]] = add i64 [[VEC_IND_SCALAR1]], 16 592; CHECK-NEXT: [[TMP10:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 593; CHECK-NEXT: br i1 [[TMP10]], label [[FOR_COND_CLEANUP:%.*]], label [[VECTOR_BODY]] 594; CHECK: for.cond.cleanup: 595; CHECK-NEXT: ret void 596; 597; CHECK-ASM-LABEL: struct_gather: 598; CHECK-ASM: # %bb.0: # %entry 599; CHECK-ASM-NEXT: addi a0, a0, 32 600; CHECK-ASM-NEXT: addi a1, a1, 132 601; CHECK-ASM-NEXT: li a2, 1024 602; CHECK-ASM-NEXT: li a3, 16 603; CHECK-ASM-NEXT: .LBB8_1: # %vector.body 604; CHECK-ASM-NEXT: # =>This Inner Loop Header: Depth=1 605; CHECK-ASM-NEXT: addi a4, a1, -128 606; CHECK-ASM-NEXT: vsetivli zero, 8, e32, m1, ta, mu 607; CHECK-ASM-NEXT: vlse32.v v8, (a4), a3 608; CHECK-ASM-NEXT: vlse32.v v9, (a1), a3 609; CHECK-ASM-NEXT: addi a4, a0, -32 610; CHECK-ASM-NEXT: vle32.v v10, (a4) 611; CHECK-ASM-NEXT: vle32.v v11, (a0) 612; CHECK-ASM-NEXT: vadd.vv v8, v10, v8 613; CHECK-ASM-NEXT: vadd.vv v9, v11, v9 614; CHECK-ASM-NEXT: vse32.v v8, (a4) 615; CHECK-ASM-NEXT: vse32.v v9, (a0) 616; CHECK-ASM-NEXT: addi a2, a2, -16 617; CHECK-ASM-NEXT: addi a0, a0, 64 618; CHECK-ASM-NEXT: addi a1, a1, 256 619; CHECK-ASM-NEXT: bnez a2, .LBB8_1 620; CHECK-ASM-NEXT: # %bb.2: # %for.cond.cleanup 621; CHECK-ASM-NEXT: ret 622entry: 623 br label %vector.body 624 625vector.body: ; preds = %vector.body, %entry 626 %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ] 627 %vec.ind = phi <8 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7>, %entry ], [ %vec.ind.next, %vector.body ] 628 %step.add = add <8 x i64> %vec.ind, <i64 8, i64 8, i64 8, i64 8, i64 8, i64 8, i64 8, i64 8> 629 %0 = getelementptr inbounds %struct.foo, %struct.foo* %B, <8 x i64> %vec.ind, i32 1 630 %1 = getelementptr inbounds %struct.foo, %struct.foo* %B, <8 x i64> %step.add, i32 1 631 %wide.masked.gather = call <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*> %0, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef) 632 %wide.masked.gather9 = call <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*> %1, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef) 633 %2 = getelementptr inbounds i32, i32* %A, i64 %index 634 %3 = bitcast i32* %2 to <8 x i32>* 635 %wide.load = load <8 x i32>, <8 x i32>* %3, align 4 636 %4 = getelementptr inbounds i32, i32* %2, i64 8 637 %5 = bitcast i32* %4 to <8 x i32>* 638 %wide.load10 = load <8 x i32>, <8 x i32>* %5, align 4 639 %6 = add nsw <8 x i32> %wide.load, %wide.masked.gather 640 %7 = add nsw <8 x i32> %wide.load10, %wide.masked.gather9 641 %8 = bitcast i32* %2 to <8 x i32>* 642 store <8 x i32> %6, <8 x i32>* %8, align 4 643 %9 = bitcast i32* %4 to <8 x i32>* 644 store <8 x i32> %7, <8 x i32>* %9, align 4 645 %index.next = add nuw i64 %index, 16 646 %vec.ind.next = add <8 x i64> %vec.ind, <i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16> 647 %10 = icmp eq i64 %index.next, 1024 648 br i1 %10, label %for.cond.cleanup, label %vector.body 649 650for.cond.cleanup: ; preds = %vector.body 651 ret void 652} 653 654;void gather_unroll(int * __restrict A, int * __restrict B) { 655; for (int i = 0; i < 1024; i+= 4 ) { 656; A[i] += B[i * 4]; 657; A[i+1] += B[(i+1) * 4]; 658; A[i+2] += B[(i+2) * 4]; 659; A[i+3] += B[(i+3) * 4]; 660; } 661;} 662define void @gather_unroll(i32* noalias nocapture %A, i32* noalias nocapture readonly %B) { 663; CHECK-LABEL: @gather_unroll( 664; CHECK-NEXT: entry: 665; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 666; CHECK: vector.body: 667; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 668; CHECK-NEXT: [[VEC_IND_SCALAR:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR:%.*]], [[VECTOR_BODY]] ] 669; CHECK-NEXT: [[VEC_IND_SCALAR1:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR2:%.*]], [[VECTOR_BODY]] ] 670; CHECK-NEXT: [[VEC_IND_SCALAR3:%.*]] = phi i64 [ 4, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR4:%.*]], [[VECTOR_BODY]] ] 671; CHECK-NEXT: [[VEC_IND_SCALAR5:%.*]] = phi i64 [ 1, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR6:%.*]], [[VECTOR_BODY]] ] 672; CHECK-NEXT: [[VEC_IND_SCALAR7:%.*]] = phi i64 [ 8, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR8:%.*]], [[VECTOR_BODY]] ] 673; CHECK-NEXT: [[VEC_IND_SCALAR9:%.*]] = phi i64 [ 2, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR10:%.*]], [[VECTOR_BODY]] ] 674; CHECK-NEXT: [[VEC_IND_SCALAR11:%.*]] = phi i64 [ 12, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR12:%.*]], [[VECTOR_BODY]] ] 675; CHECK-NEXT: [[VEC_IND_SCALAR13:%.*]] = phi i64 [ 3, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR14:%.*]], [[VECTOR_BODY]] ] 676; CHECK-NEXT: [[VEC_IND_SCALAR15:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR16:%.*]], [[VECTOR_BODY]] ] 677; CHECK-NEXT: [[VEC_IND_SCALAR17:%.*]] = phi i64 [ 1, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR18:%.*]], [[VECTOR_BODY]] ] 678; CHECK-NEXT: [[VEC_IND_SCALAR19:%.*]] = phi i64 [ 2, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR20:%.*]], [[VECTOR_BODY]] ] 679; CHECK-NEXT: [[VEC_IND_SCALAR21:%.*]] = phi i64 [ 3, [[ENTRY]] ], [ [[VEC_IND_NEXT_SCALAR22:%.*]], [[VECTOR_BODY]] ] 680; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i32, i32* [[B:%.*]], i64 [[VEC_IND_SCALAR]] 681; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <8 x i32> @llvm.riscv.masked.strided.load.v8i32.p0i32.i64(<8 x i32> undef, i32* [[TMP0]], i64 64, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 682; CHECK-NEXT: [[TMP1:%.*]] = getelementptr i32, i32* [[A:%.*]], i64 [[VEC_IND_SCALAR1]] 683; CHECK-NEXT: [[TMP2:%.*]] = getelementptr i32, i32* [[A]], i64 [[VEC_IND_SCALAR15]] 684; CHECK-NEXT: [[WIDE_MASKED_GATHER52:%.*]] = call <8 x i32> @llvm.riscv.masked.strided.load.v8i32.p0i32.i64(<8 x i32> undef, i32* [[TMP1]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 685; CHECK-NEXT: [[TMP3:%.*]] = add nsw <8 x i32> [[WIDE_MASKED_GATHER52]], [[WIDE_MASKED_GATHER]] 686; CHECK-NEXT: call void @llvm.riscv.masked.strided.store.v8i32.p0i32.i64(<8 x i32> [[TMP3]], i32* [[TMP2]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 687; CHECK-NEXT: [[TMP4:%.*]] = getelementptr i32, i32* [[B]], i64 [[VEC_IND_SCALAR3]] 688; CHECK-NEXT: [[WIDE_MASKED_GATHER53:%.*]] = call <8 x i32> @llvm.riscv.masked.strided.load.v8i32.p0i32.i64(<8 x i32> undef, i32* [[TMP4]], i64 64, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 689; CHECK-NEXT: [[TMP5:%.*]] = getelementptr i32, i32* [[A]], i64 [[VEC_IND_SCALAR5]] 690; CHECK-NEXT: [[TMP6:%.*]] = getelementptr i32, i32* [[A]], i64 [[VEC_IND_SCALAR17]] 691; CHECK-NEXT: [[WIDE_MASKED_GATHER54:%.*]] = call <8 x i32> @llvm.riscv.masked.strided.load.v8i32.p0i32.i64(<8 x i32> undef, i32* [[TMP5]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 692; CHECK-NEXT: [[TMP7:%.*]] = add nsw <8 x i32> [[WIDE_MASKED_GATHER54]], [[WIDE_MASKED_GATHER53]] 693; CHECK-NEXT: call void @llvm.riscv.masked.strided.store.v8i32.p0i32.i64(<8 x i32> [[TMP7]], i32* [[TMP6]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 694; CHECK-NEXT: [[TMP8:%.*]] = getelementptr i32, i32* [[B]], i64 [[VEC_IND_SCALAR7]] 695; CHECK-NEXT: [[WIDE_MASKED_GATHER55:%.*]] = call <8 x i32> @llvm.riscv.masked.strided.load.v8i32.p0i32.i64(<8 x i32> undef, i32* [[TMP8]], i64 64, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 696; CHECK-NEXT: [[TMP9:%.*]] = getelementptr i32, i32* [[A]], i64 [[VEC_IND_SCALAR9]] 697; CHECK-NEXT: [[TMP10:%.*]] = getelementptr i32, i32* [[A]], i64 [[VEC_IND_SCALAR19]] 698; CHECK-NEXT: [[WIDE_MASKED_GATHER56:%.*]] = call <8 x i32> @llvm.riscv.masked.strided.load.v8i32.p0i32.i64(<8 x i32> undef, i32* [[TMP9]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 699; CHECK-NEXT: [[TMP11:%.*]] = add nsw <8 x i32> [[WIDE_MASKED_GATHER56]], [[WIDE_MASKED_GATHER55]] 700; CHECK-NEXT: call void @llvm.riscv.masked.strided.store.v8i32.p0i32.i64(<8 x i32> [[TMP11]], i32* [[TMP10]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 701; CHECK-NEXT: [[TMP12:%.*]] = getelementptr i32, i32* [[B]], i64 [[VEC_IND_SCALAR11]] 702; CHECK-NEXT: [[WIDE_MASKED_GATHER57:%.*]] = call <8 x i32> @llvm.riscv.masked.strided.load.v8i32.p0i32.i64(<8 x i32> undef, i32* [[TMP12]], i64 64, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 703; CHECK-NEXT: [[TMP13:%.*]] = getelementptr i32, i32* [[A]], i64 [[VEC_IND_SCALAR13]] 704; CHECK-NEXT: [[TMP14:%.*]] = getelementptr i32, i32* [[A]], i64 [[VEC_IND_SCALAR21]] 705; CHECK-NEXT: [[WIDE_MASKED_GATHER58:%.*]] = call <8 x i32> @llvm.riscv.masked.strided.load.v8i32.p0i32.i64(<8 x i32> undef, i32* [[TMP13]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 706; CHECK-NEXT: [[TMP15:%.*]] = add nsw <8 x i32> [[WIDE_MASKED_GATHER58]], [[WIDE_MASKED_GATHER57]] 707; CHECK-NEXT: call void @llvm.riscv.masked.strided.store.v8i32.p0i32.i64(<8 x i32> [[TMP15]], i32* [[TMP14]], i64 16, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 708; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 8 709; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR]] = add i64 [[VEC_IND_SCALAR]], 128 710; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR2]] = add i64 [[VEC_IND_SCALAR1]], 32 711; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR4]] = add i64 [[VEC_IND_SCALAR3]], 128 712; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR6]] = add i64 [[VEC_IND_SCALAR5]], 32 713; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR8]] = add i64 [[VEC_IND_SCALAR7]], 128 714; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR10]] = add i64 [[VEC_IND_SCALAR9]], 32 715; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR12]] = add i64 [[VEC_IND_SCALAR11]], 128 716; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR14]] = add i64 [[VEC_IND_SCALAR13]], 32 717; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR16]] = add i64 [[VEC_IND_SCALAR15]], 32 718; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR18]] = add i64 [[VEC_IND_SCALAR17]], 32 719; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR20]] = add i64 [[VEC_IND_SCALAR19]], 32 720; CHECK-NEXT: [[VEC_IND_NEXT_SCALAR22]] = add i64 [[VEC_IND_SCALAR21]], 32 721; CHECK-NEXT: [[TMP16:%.*]] = icmp eq i64 [[INDEX_NEXT]], 256 722; CHECK-NEXT: br i1 [[TMP16]], label [[FOR_COND_CLEANUP:%.*]], label [[VECTOR_BODY]] 723; CHECK: for.cond.cleanup: 724; CHECK-NEXT: ret void 725; 726; CHECK-ASM-LABEL: gather_unroll: 727; CHECK-ASM: # %bb.0: # %entry 728; CHECK-ASM-NEXT: li a2, 256 729; CHECK-ASM-NEXT: li a3, 64 730; CHECK-ASM-NEXT: li a4, 16 731; CHECK-ASM-NEXT: .LBB9_1: # %vector.body 732; CHECK-ASM-NEXT: # =>This Inner Loop Header: Depth=1 733; CHECK-ASM-NEXT: vsetivli zero, 8, e32, m1, ta, mu 734; CHECK-ASM-NEXT: vlse32.v v8, (a1), a3 735; CHECK-ASM-NEXT: vlse32.v v9, (a0), a4 736; CHECK-ASM-NEXT: vadd.vv v8, v9, v8 737; CHECK-ASM-NEXT: vsse32.v v8, (a0), a4 738; CHECK-ASM-NEXT: addi a5, a1, 16 739; CHECK-ASM-NEXT: vlse32.v v8, (a5), a3 740; CHECK-ASM-NEXT: addi a5, a0, 4 741; CHECK-ASM-NEXT: vlse32.v v9, (a5), a4 742; CHECK-ASM-NEXT: vadd.vv v8, v9, v8 743; CHECK-ASM-NEXT: vsse32.v v8, (a5), a4 744; CHECK-ASM-NEXT: addi a5, a1, 32 745; CHECK-ASM-NEXT: vlse32.v v8, (a5), a3 746; CHECK-ASM-NEXT: addi a5, a0, 8 747; CHECK-ASM-NEXT: vlse32.v v9, (a5), a4 748; CHECK-ASM-NEXT: vadd.vv v8, v9, v8 749; CHECK-ASM-NEXT: vsse32.v v8, (a5), a4 750; CHECK-ASM-NEXT: addi a5, a1, 48 751; CHECK-ASM-NEXT: vlse32.v v8, (a5), a3 752; CHECK-ASM-NEXT: addi a5, a0, 12 753; CHECK-ASM-NEXT: vlse32.v v9, (a5), a4 754; CHECK-ASM-NEXT: vadd.vv v8, v9, v8 755; CHECK-ASM-NEXT: vsse32.v v8, (a5), a4 756; CHECK-ASM-NEXT: addi a2, a2, -8 757; CHECK-ASM-NEXT: addi a1, a1, 512 758; CHECK-ASM-NEXT: addi a0, a0, 128 759; CHECK-ASM-NEXT: bnez a2, .LBB9_1 760; CHECK-ASM-NEXT: # %bb.2: # %for.cond.cleanup 761; CHECK-ASM-NEXT: ret 762entry: 763 br label %vector.body 764 765vector.body: ; preds = %vector.body, %entry 766 %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ] 767 %vec.ind = phi <8 x i64> [ <i64 0, i64 4, i64 8, i64 12, i64 16, i64 20, i64 24, i64 28>, %entry ], [ %vec.ind.next, %vector.body ] 768 %0 = shl nuw nsw <8 x i64> %vec.ind, <i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2> 769 %1 = getelementptr inbounds i32, i32* %B, <8 x i64> %0 770 %wide.masked.gather = call <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*> %1, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef) 771 %2 = getelementptr inbounds i32, i32* %A, <8 x i64> %vec.ind 772 %wide.masked.gather52 = call <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*> %2, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef) 773 %3 = add nsw <8 x i32> %wide.masked.gather52, %wide.masked.gather 774 call void @llvm.masked.scatter.v8i32.v8p0i32(<8 x i32> %3, <8 x i32*> %2, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 775 %4 = or <8 x i64> %vec.ind, <i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1> 776 %5 = shl nsw <8 x i64> %4, <i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2> 777 %6 = getelementptr inbounds i32, i32* %B, <8 x i64> %5 778 %wide.masked.gather53 = call <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*> %6, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef) 779 %7 = getelementptr inbounds i32, i32* %A, <8 x i64> %4 780 %wide.masked.gather54 = call <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*> %7, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef) 781 %8 = add nsw <8 x i32> %wide.masked.gather54, %wide.masked.gather53 782 call void @llvm.masked.scatter.v8i32.v8p0i32(<8 x i32> %8, <8 x i32*> %7, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 783 %9 = or <8 x i64> %vec.ind, <i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2> 784 %10 = shl nsw <8 x i64> %9, <i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2> 785 %11 = getelementptr inbounds i32, i32* %B, <8 x i64> %10 786 %wide.masked.gather55 = call <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*> %11, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef) 787 %12 = getelementptr inbounds i32, i32* %A, <8 x i64> %9 788 %wide.masked.gather56 = call <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*> %12, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef) 789 %13 = add nsw <8 x i32> %wide.masked.gather56, %wide.masked.gather55 790 call void @llvm.masked.scatter.v8i32.v8p0i32(<8 x i32> %13, <8 x i32*> %12, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 791 %14 = or <8 x i64> %vec.ind, <i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3> 792 %15 = shl nsw <8 x i64> %14, <i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2> 793 %16 = getelementptr inbounds i32, i32* %B, <8 x i64> %15 794 %wide.masked.gather57 = call <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*> %16, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef) 795 %17 = getelementptr inbounds i32, i32* %A, <8 x i64> %14 796 %wide.masked.gather58 = call <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*> %17, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i32> undef) 797 %18 = add nsw <8 x i32> %wide.masked.gather58, %wide.masked.gather57 798 call void @llvm.masked.scatter.v8i32.v8p0i32(<8 x i32> %18, <8 x i32*> %17, i32 4, <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 799 %index.next = add nuw i64 %index, 8 800 %vec.ind.next = add <8 x i64> %vec.ind, <i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32> 801 %19 = icmp eq i64 %index.next, 256 802 br i1 %19, label %for.cond.cleanup, label %vector.body 803 804for.cond.cleanup: ; preds = %vector.body 805 ret void 806} 807 808declare <32 x i8> @llvm.masked.gather.v32i8.v32p0i8(<32 x i8*>, i32 immarg, <32 x i1>, <32 x i8>) 809declare <8 x i32> @llvm.masked.gather.v8i32.v8p0i32(<8 x i32*>, i32 immarg, <8 x i1>, <8 x i32>) 810declare void @llvm.masked.scatter.v32i8.v32p0i8(<32 x i8>, <32 x i8*>, i32 immarg, <32 x i1>) 811declare void @llvm.masked.scatter.v8i32.v8p0i32(<8 x i32>, <8 x i32*>, i32 immarg, <8 x i1>) 812 813; Make sure we don't crash in getTgtMemIntrinsic for a vector of pointers. 814define void @gather_of_pointers(i32** noalias nocapture %0, i32** noalias nocapture readonly %1) { 815; CHECK-LABEL: @gather_of_pointers( 816; CHECK-NEXT: br label [[TMP3:%.*]] 817; CHECK: 3: 818; CHECK-NEXT: [[TMP4:%.*]] = phi i64 [ 0, [[TMP2:%.*]] ], [ [[TMP13:%.*]], [[TMP3]] ] 819; CHECK-NEXT: [[DOTSCALAR:%.*]] = phi i64 [ 0, [[TMP2]] ], [ [[DOTSCALAR1:%.*]], [[TMP3]] ] 820; CHECK-NEXT: [[DOTSCALAR2:%.*]] = phi i64 [ 10, [[TMP2]] ], [ [[DOTSCALAR3:%.*]], [[TMP3]] ] 821; CHECK-NEXT: [[TMP5:%.*]] = getelementptr i32*, i32** [[TMP1:%.*]], i64 [[DOTSCALAR]] 822; CHECK-NEXT: [[TMP6:%.*]] = getelementptr i32*, i32** [[TMP1]], i64 [[DOTSCALAR2]] 823; CHECK-NEXT: [[TMP7:%.*]] = call <2 x i32*> @llvm.riscv.masked.strided.load.v2p0i32.p0p0i32.i64(<2 x i32*> undef, i32** [[TMP5]], i64 40, <2 x i1> <i1 true, i1 true>) 824; CHECK-NEXT: [[TMP8:%.*]] = call <2 x i32*> @llvm.riscv.masked.strided.load.v2p0i32.p0p0i32.i64(<2 x i32*> undef, i32** [[TMP6]], i64 40, <2 x i1> <i1 true, i1 true>) 825; CHECK-NEXT: [[TMP9:%.*]] = getelementptr inbounds i32*, i32** [[TMP0:%.*]], i64 [[TMP4]] 826; CHECK-NEXT: [[TMP10:%.*]] = bitcast i32** [[TMP9]] to <2 x i32*>* 827; CHECK-NEXT: store <2 x i32*> [[TMP7]], <2 x i32*>* [[TMP10]], align 8 828; CHECK-NEXT: [[TMP11:%.*]] = getelementptr inbounds i32*, i32** [[TMP9]], i64 2 829; CHECK-NEXT: [[TMP12:%.*]] = bitcast i32** [[TMP11]] to <2 x i32*>* 830; CHECK-NEXT: store <2 x i32*> [[TMP8]], <2 x i32*>* [[TMP12]], align 8 831; CHECK-NEXT: [[TMP13]] = add nuw i64 [[TMP4]], 4 832; CHECK-NEXT: [[DOTSCALAR1]] = add i64 [[DOTSCALAR]], 20 833; CHECK-NEXT: [[DOTSCALAR3]] = add i64 [[DOTSCALAR2]], 20 834; CHECK-NEXT: [[TMP14:%.*]] = icmp eq i64 [[TMP13]], 1024 835; CHECK-NEXT: br i1 [[TMP14]], label [[TMP15:%.*]], label [[TMP3]] 836; CHECK: 15: 837; CHECK-NEXT: ret void 838; 839; CHECK-ASM-LABEL: gather_of_pointers: 840; CHECK-ASM: # %bb.0: 841; CHECK-ASM-NEXT: addi a0, a0, 16 842; CHECK-ASM-NEXT: li a2, 1024 843; CHECK-ASM-NEXT: li a3, 40 844; CHECK-ASM-NEXT: .LBB10_1: # =>This Inner Loop Header: Depth=1 845; CHECK-ASM-NEXT: addi a4, a1, 80 846; CHECK-ASM-NEXT: vsetivli zero, 2, e64, m1, ta, mu 847; CHECK-ASM-NEXT: vlse64.v v8, (a1), a3 848; CHECK-ASM-NEXT: vlse64.v v9, (a4), a3 849; CHECK-ASM-NEXT: addi a4, a0, -16 850; CHECK-ASM-NEXT: vse64.v v8, (a4) 851; CHECK-ASM-NEXT: vse64.v v9, (a0) 852; CHECK-ASM-NEXT: addi a2, a2, -4 853; CHECK-ASM-NEXT: addi a0, a0, 32 854; CHECK-ASM-NEXT: addi a1, a1, 160 855; CHECK-ASM-NEXT: bnez a2, .LBB10_1 856; CHECK-ASM-NEXT: # %bb.2: 857; CHECK-ASM-NEXT: ret 858 br label %3 859 8603: ; preds = %3, %2 861 %4 = phi i64 [ 0, %2 ], [ %17, %3 ] 862 %5 = phi <2 x i64> [ <i64 0, i64 1>, %2 ], [ %18, %3 ] 863 %6 = mul nuw nsw <2 x i64> %5, <i64 5, i64 5> 864 %7 = mul <2 x i64> %5, <i64 5, i64 5> 865 %8 = add <2 x i64> %7, <i64 10, i64 10> 866 %9 = getelementptr inbounds i32*, i32** %1, <2 x i64> %6 867 %10 = getelementptr inbounds i32*, i32** %1, <2 x i64> %8 868 %11 = call <2 x i32*> @llvm.masked.gather.v2p0i32.v2p0p0i32(<2 x i32**> %9, i32 8, <2 x i1> <i1 true, i1 true>, <2 x i32*> undef) 869 %12 = call <2 x i32*> @llvm.masked.gather.v2p0i32.v2p0p0i32(<2 x i32**> %10, i32 8, <2 x i1> <i1 true, i1 true>, <2 x i32*> undef) 870 %13 = getelementptr inbounds i32*, i32** %0, i64 %4 871 %14 = bitcast i32** %13 to <2 x i32*>* 872 store <2 x i32*> %11, <2 x i32*>* %14, align 8 873 %15 = getelementptr inbounds i32*, i32** %13, i64 2 874 %16 = bitcast i32** %15 to <2 x i32*>* 875 store <2 x i32*> %12, <2 x i32*>* %16, align 8 876 %17 = add nuw i64 %4, 4 877 %18 = add <2 x i64> %5, <i64 4, i64 4> 878 %19 = icmp eq i64 %17, 1024 879 br i1 %19, label %20, label %3 880 88120: ; preds = %3 882 ret void 883} 884 885declare <2 x i32*> @llvm.masked.gather.v2p0i32.v2p0p0i32(<2 x i32**>, i32 immarg, <2 x i1>, <2 x i32*>) 886 887; Make sure we don't crash in getTgtMemIntrinsic for a vector of pointers. 888define void @scatter_of_pointers(i32** noalias nocapture %0, i32** noalias nocapture readonly %1) { 889; CHECK-LABEL: @scatter_of_pointers( 890; CHECK-NEXT: br label [[TMP3:%.*]] 891; CHECK: 3: 892; CHECK-NEXT: [[TMP4:%.*]] = phi i64 [ 0, [[TMP2:%.*]] ], [ [[TMP13:%.*]], [[TMP3]] ] 893; CHECK-NEXT: [[DOTSCALAR:%.*]] = phi i64 [ 0, [[TMP2]] ], [ [[DOTSCALAR1:%.*]], [[TMP3]] ] 894; CHECK-NEXT: [[DOTSCALAR2:%.*]] = phi i64 [ 10, [[TMP2]] ], [ [[DOTSCALAR3:%.*]], [[TMP3]] ] 895; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds i32*, i32** [[TMP1:%.*]], i64 [[TMP4]] 896; CHECK-NEXT: [[TMP6:%.*]] = bitcast i32** [[TMP5]] to <2 x i32*>* 897; CHECK-NEXT: [[TMP7:%.*]] = load <2 x i32*>, <2 x i32*>* [[TMP6]], align 8 898; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds i32*, i32** [[TMP5]], i64 2 899; CHECK-NEXT: [[TMP9:%.*]] = bitcast i32** [[TMP8]] to <2 x i32*>* 900; CHECK-NEXT: [[TMP10:%.*]] = load <2 x i32*>, <2 x i32*>* [[TMP9]], align 8 901; CHECK-NEXT: [[TMP11:%.*]] = getelementptr i32*, i32** [[TMP0:%.*]], i64 [[DOTSCALAR]] 902; CHECK-NEXT: [[TMP12:%.*]] = getelementptr i32*, i32** [[TMP0]], i64 [[DOTSCALAR2]] 903; CHECK-NEXT: call void @llvm.riscv.masked.strided.store.v2p0i32.p0p0i32.i64(<2 x i32*> [[TMP7]], i32** [[TMP11]], i64 40, <2 x i1> <i1 true, i1 true>) 904; CHECK-NEXT: call void @llvm.riscv.masked.strided.store.v2p0i32.p0p0i32.i64(<2 x i32*> [[TMP10]], i32** [[TMP12]], i64 40, <2 x i1> <i1 true, i1 true>) 905; CHECK-NEXT: [[TMP13]] = add nuw i64 [[TMP4]], 4 906; CHECK-NEXT: [[DOTSCALAR1]] = add i64 [[DOTSCALAR]], 20 907; CHECK-NEXT: [[DOTSCALAR3]] = add i64 [[DOTSCALAR2]], 20 908; CHECK-NEXT: [[TMP14:%.*]] = icmp eq i64 [[TMP13]], 1024 909; CHECK-NEXT: br i1 [[TMP14]], label [[TMP15:%.*]], label [[TMP3]] 910; CHECK: 15: 911; CHECK-NEXT: ret void 912; 913; CHECK-ASM-LABEL: scatter_of_pointers: 914; CHECK-ASM: # %bb.0: 915; CHECK-ASM-NEXT: addi a1, a1, 16 916; CHECK-ASM-NEXT: li a2, 1024 917; CHECK-ASM-NEXT: li a3, 40 918; CHECK-ASM-NEXT: .LBB11_1: # =>This Inner Loop Header: Depth=1 919; CHECK-ASM-NEXT: addi a4, a1, -16 920; CHECK-ASM-NEXT: vsetivli zero, 2, e64, m1, ta, mu 921; CHECK-ASM-NEXT: vle64.v v8, (a4) 922; CHECK-ASM-NEXT: vle64.v v9, (a1) 923; CHECK-ASM-NEXT: addi a4, a0, 80 924; CHECK-ASM-NEXT: vsse64.v v8, (a0), a3 925; CHECK-ASM-NEXT: vsse64.v v9, (a4), a3 926; CHECK-ASM-NEXT: addi a2, a2, -4 927; CHECK-ASM-NEXT: addi a1, a1, 32 928; CHECK-ASM-NEXT: addi a0, a0, 160 929; CHECK-ASM-NEXT: bnez a2, .LBB11_1 930; CHECK-ASM-NEXT: # %bb.2: 931; CHECK-ASM-NEXT: ret 932 br label %3 933 9343: ; preds = %3, %2 935 %4 = phi i64 [ 0, %2 ], [ %17, %3 ] 936 %5 = phi <2 x i64> [ <i64 0, i64 1>, %2 ], [ %18, %3 ] 937 %6 = getelementptr inbounds i32*, i32** %1, i64 %4 938 %7 = bitcast i32** %6 to <2 x i32*>* 939 %8 = load <2 x i32*>, <2 x i32*>* %7, align 8 940 %9 = getelementptr inbounds i32*, i32** %6, i64 2 941 %10 = bitcast i32** %9 to <2 x i32*>* 942 %11 = load <2 x i32*>, <2 x i32*>* %10, align 8 943 %12 = mul nuw nsw <2 x i64> %5, <i64 5, i64 5> 944 %13 = mul <2 x i64> %5, <i64 5, i64 5> 945 %14 = add <2 x i64> %13, <i64 10, i64 10> 946 %15 = getelementptr inbounds i32*, i32** %0, <2 x i64> %12 947 %16 = getelementptr inbounds i32*, i32** %0, <2 x i64> %14 948 call void @llvm.masked.scatter.v2p0i32.v2p0p0i32(<2 x i32*> %8, <2 x i32**> %15, i32 8, <2 x i1> <i1 true, i1 true>) 949 call void @llvm.masked.scatter.v2p0i32.v2p0p0i32(<2 x i32*> %11, <2 x i32**> %16, i32 8, <2 x i1> <i1 true, i1 true>) 950 %17 = add nuw i64 %4, 4 951 %18 = add <2 x i64> %5, <i64 4, i64 4> 952 %19 = icmp eq i64 %17, 1024 953 br i1 %19, label %20, label %3 954 95520: ; preds = %3 956 ret void 957} 958 959declare void @llvm.masked.scatter.v2p0i32.v2p0p0i32(<2 x i32*>, <2 x i32**>, i32 immarg, <2 x i1>) 960 961define void @strided_load_startval_add_with_splat(i8* noalias nocapture %0, i8* noalias nocapture readonly %1, i32 signext %2) { 962; CHECK-LABEL: @strided_load_startval_add_with_splat( 963; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i32 [[TMP2:%.*]], 1024 964; CHECK-NEXT: br i1 [[TMP4]], label [[TMP31:%.*]], label [[TMP5:%.*]] 965; CHECK: 5: 966; CHECK-NEXT: [[TMP6:%.*]] = sext i32 [[TMP2]] to i64 967; CHECK-NEXT: [[TMP7:%.*]] = sub i32 1023, [[TMP2]] 968; CHECK-NEXT: [[TMP8:%.*]] = zext i32 [[TMP7]] to i64 969; CHECK-NEXT: [[TMP9:%.*]] = add nuw nsw i64 [[TMP8]], 1 970; CHECK-NEXT: [[TMP10:%.*]] = icmp ult i32 [[TMP7]], 31 971; CHECK-NEXT: br i1 [[TMP10]], label [[TMP29:%.*]], label [[TMP11:%.*]] 972; CHECK: 11: 973; CHECK-NEXT: [[TMP12:%.*]] = and i64 [[TMP9]], 8589934560 974; CHECK-NEXT: [[TMP13:%.*]] = add nsw i64 [[TMP12]], [[TMP6]] 975; CHECK-NEXT: [[TMP14:%.*]] = add i64 0, [[TMP6]] 976; CHECK-NEXT: [[START:%.*]] = mul i64 [[TMP14]], 5 977; CHECK-NEXT: br label [[TMP15:%.*]] 978; CHECK: 15: 979; CHECK-NEXT: [[TMP16:%.*]] = phi i64 [ 0, [[TMP11]] ], [ [[TMP25:%.*]], [[TMP15]] ] 980; CHECK-NEXT: [[DOTSCALAR:%.*]] = phi i64 [ [[START]], [[TMP11]] ], [ [[DOTSCALAR1:%.*]], [[TMP15]] ] 981; CHECK-NEXT: [[TMP17:%.*]] = add i64 [[TMP16]], [[TMP6]] 982; CHECK-NEXT: [[TMP18:%.*]] = getelementptr i8, i8* [[TMP1:%.*]], i64 [[DOTSCALAR]] 983; CHECK-NEXT: [[TMP19:%.*]] = call <32 x i8> @llvm.riscv.masked.strided.load.v32i8.p0i8.i64(<32 x i8> undef, i8* [[TMP18]], i64 5, <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>) 984; CHECK-NEXT: [[TMP20:%.*]] = getelementptr inbounds i8, i8* [[TMP0:%.*]], i64 [[TMP17]] 985; CHECK-NEXT: [[TMP21:%.*]] = bitcast i8* [[TMP20]] to <32 x i8>* 986; CHECK-NEXT: [[TMP22:%.*]] = load <32 x i8>, <32 x i8>* [[TMP21]], align 1 987; CHECK-NEXT: [[TMP23:%.*]] = add <32 x i8> [[TMP22]], [[TMP19]] 988; CHECK-NEXT: [[TMP24:%.*]] = bitcast i8* [[TMP20]] to <32 x i8>* 989; CHECK-NEXT: store <32 x i8> [[TMP23]], <32 x i8>* [[TMP24]], align 1 990; CHECK-NEXT: [[TMP25]] = add nuw i64 [[TMP16]], 32 991; CHECK-NEXT: [[DOTSCALAR1]] = add i64 [[DOTSCALAR]], 160 992; CHECK-NEXT: [[TMP26:%.*]] = icmp eq i64 [[TMP25]], [[TMP12]] 993; CHECK-NEXT: br i1 [[TMP26]], label [[TMP27:%.*]], label [[TMP15]] 994; CHECK: 27: 995; CHECK-NEXT: [[TMP28:%.*]] = icmp eq i64 [[TMP9]], [[TMP12]] 996; CHECK-NEXT: br i1 [[TMP28]], label [[TMP31]], label [[TMP29]] 997; CHECK: 29: 998; CHECK-NEXT: [[TMP30:%.*]] = phi i64 [ [[TMP6]], [[TMP5]] ], [ [[TMP13]], [[TMP27]] ] 999; CHECK-NEXT: br label [[TMP32:%.*]] 1000; CHECK: 31: 1001; CHECK-NEXT: ret void 1002; CHECK: 32: 1003; CHECK-NEXT: [[TMP33:%.*]] = phi i64 [ [[TMP40:%.*]], [[TMP32]] ], [ [[TMP30]], [[TMP29]] ] 1004; CHECK-NEXT: [[TMP34:%.*]] = mul nsw i64 [[TMP33]], 5 1005; CHECK-NEXT: [[TMP35:%.*]] = getelementptr inbounds i8, i8* [[TMP1]], i64 [[TMP34]] 1006; CHECK-NEXT: [[TMP36:%.*]] = load i8, i8* [[TMP35]], align 1 1007; CHECK-NEXT: [[TMP37:%.*]] = getelementptr inbounds i8, i8* [[TMP0]], i64 [[TMP33]] 1008; CHECK-NEXT: [[TMP38:%.*]] = load i8, i8* [[TMP37]], align 1 1009; CHECK-NEXT: [[TMP39:%.*]] = add i8 [[TMP38]], [[TMP36]] 1010; CHECK-NEXT: store i8 [[TMP39]], i8* [[TMP37]], align 1 1011; CHECK-NEXT: [[TMP40]] = add nsw i64 [[TMP33]], 1 1012; CHECK-NEXT: [[TMP41:%.*]] = trunc i64 [[TMP40]] to i32 1013; CHECK-NEXT: [[TMP42:%.*]] = icmp eq i32 [[TMP41]], 1024 1014; CHECK-NEXT: br i1 [[TMP42]], label [[TMP31]], label [[TMP32]] 1015; 1016; CHECK-ASM-LABEL: strided_load_startval_add_with_splat: 1017; CHECK-ASM: # %bb.0: 1018; CHECK-ASM-NEXT: li a3, 1024 1019; CHECK-ASM-NEXT: beq a2, a3, .LBB12_7 1020; CHECK-ASM-NEXT: # %bb.1: 1021; CHECK-ASM-NEXT: li a3, 1023 1022; CHECK-ASM-NEXT: subw a4, a3, a2 1023; CHECK-ASM-NEXT: li a5, 31 1024; CHECK-ASM-NEXT: mv a3, a2 1025; CHECK-ASM-NEXT: bltu a4, a5, .LBB12_5 1026; CHECK-ASM-NEXT: # %bb.2: 1027; CHECK-ASM-NEXT: slli a3, a4, 32 1028; CHECK-ASM-NEXT: srli a3, a3, 32 1029; CHECK-ASM-NEXT: addi a4, a3, 1 1030; CHECK-ASM-NEXT: andi a5, a4, -32 1031; CHECK-ASM-NEXT: add a3, a5, a2 1032; CHECK-ASM-NEXT: slli a6, a2, 2 1033; CHECK-ASM-NEXT: add a6, a6, a2 1034; CHECK-ASM-NEXT: add a2, a0, a2 1035; CHECK-ASM-NEXT: add a6, a1, a6 1036; CHECK-ASM-NEXT: li a7, 32 1037; CHECK-ASM-NEXT: li t0, 5 1038; CHECK-ASM-NEXT: mv t1, a5 1039; CHECK-ASM-NEXT: .LBB12_3: # =>This Inner Loop Header: Depth=1 1040; CHECK-ASM-NEXT: vsetvli zero, a7, e8, m1, ta, mu 1041; CHECK-ASM-NEXT: vlse8.v v8, (a6), t0 1042; CHECK-ASM-NEXT: vle8.v v9, (a2) 1043; CHECK-ASM-NEXT: vadd.vv v8, v9, v8 1044; CHECK-ASM-NEXT: vse8.v v8, (a2) 1045; CHECK-ASM-NEXT: addi t1, t1, -32 1046; CHECK-ASM-NEXT: addi a2, a2, 32 1047; CHECK-ASM-NEXT: addi a6, a6, 160 1048; CHECK-ASM-NEXT: bnez t1, .LBB12_3 1049; CHECK-ASM-NEXT: # %bb.4: 1050; CHECK-ASM-NEXT: beq a4, a5, .LBB12_7 1051; CHECK-ASM-NEXT: .LBB12_5: 1052; CHECK-ASM-NEXT: slli a2, a3, 2 1053; CHECK-ASM-NEXT: add a2, a2, a3 1054; CHECK-ASM-NEXT: add a1, a1, a2 1055; CHECK-ASM-NEXT: li a2, 1024 1056; CHECK-ASM-NEXT: .LBB12_6: # =>This Inner Loop Header: Depth=1 1057; CHECK-ASM-NEXT: lb a4, 0(a1) 1058; CHECK-ASM-NEXT: add a5, a0, a3 1059; CHECK-ASM-NEXT: lb a6, 0(a5) 1060; CHECK-ASM-NEXT: addw a4, a6, a4 1061; CHECK-ASM-NEXT: sb a4, 0(a5) 1062; CHECK-ASM-NEXT: addiw a4, a3, 1 1063; CHECK-ASM-NEXT: addi a3, a3, 1 1064; CHECK-ASM-NEXT: addi a1, a1, 5 1065; CHECK-ASM-NEXT: bne a4, a2, .LBB12_6 1066; CHECK-ASM-NEXT: .LBB12_7: 1067; CHECK-ASM-NEXT: ret 1068 %4 = icmp eq i32 %2, 1024 1069 br i1 %4, label %36, label %5 1070 10715: ; preds = %3 1072 %6 = sext i32 %2 to i64 1073 %7 = sub i32 1023, %2 1074 %8 = zext i32 %7 to i64 1075 %9 = add nuw nsw i64 %8, 1 1076 %10 = icmp ult i32 %7, 31 1077 br i1 %10, label %34, label %11 1078 107911: ; preds = %5 1080 %12 = and i64 %9, 8589934560 1081 %13 = add nsw i64 %12, %6 1082 %14 = insertelement <32 x i64> poison, i64 %6, i64 0 1083 %15 = shufflevector <32 x i64> %14, <32 x i64> poison, <32 x i32> zeroinitializer 1084 %16 = add <32 x i64> %15, <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16, i64 17, i64 18, i64 19, i64 20, i64 21, i64 22, i64 23, i64 24, i64 25, i64 26, i64 27, i64 28, i64 29, i64 30, i64 31> 1085 br label %17 1086 108717: ; preds = %17, %11 1088 %18 = phi i64 [ 0, %11 ], [ %29, %17 ] 1089 %19 = phi <32 x i64> [ %16, %11 ], [ %30, %17 ] 1090 %20 = add i64 %18, %6 1091 %21 = mul nsw <32 x i64> %19, <i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5, i64 5> 1092 %22 = getelementptr inbounds i8, i8* %1, <32 x i64> %21 1093 %23 = call <32 x i8> @llvm.masked.gather.v32i8.v32p0i8(<32 x i8*> %22, i32 1, <32 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <32 x i8> undef) 1094 %24 = getelementptr inbounds i8, i8* %0, i64 %20 1095 %25 = bitcast i8* %24 to <32 x i8>* 1096 %26 = load <32 x i8>, <32 x i8>* %25, align 1 1097 %27 = add <32 x i8> %26, %23 1098 %28 = bitcast i8* %24 to <32 x i8>* 1099 store <32 x i8> %27, <32 x i8>* %28, align 1 1100 %29 = add nuw i64 %18, 32 1101 %30 = add <32 x i64> %19, <i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32> 1102 %31 = icmp eq i64 %29, %12 1103 br i1 %31, label %32, label %17 1104 110532: ; preds = %17 1106 %33 = icmp eq i64 %9, %12 1107 br i1 %33, label %36, label %34 1108 110934: ; preds = %5, %32 1110 %35 = phi i64 [ %6, %5 ], [ %13, %32 ] 1111 br label %37 1112 111336: ; preds = %37, %32, %3 1114 ret void 1115 111637: ; preds = %34, %37 1117 %38 = phi i64 [ %45, %37 ], [ %35, %34 ] 1118 %39 = mul nsw i64 %38, 5 1119 %40 = getelementptr inbounds i8, i8* %1, i64 %39 1120 %41 = load i8, i8* %40, align 1 1121 %42 = getelementptr inbounds i8, i8* %0, i64 %38 1122 %43 = load i8, i8* %42, align 1 1123 %44 = add i8 %43, %41 1124 store i8 %44, i8* %42, align 1 1125 %45 = add nsw i64 %38, 1 1126 %46 = trunc i64 %45 to i32 1127 %47 = icmp eq i32 %46, 1024 1128 br i1 %47, label %36, label %37 1129} 1130