| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | |
| ; RUN: opt -passes=loop-vectorize -mtriple=riscv64 -mattr=+v -vplan-verify-each -S < %s | FileCheck %s | |
| define void @trip1_i8(ptr noalias nocapture noundef %dst, ptr noalias nocapture noundef readonly %src) #0 { | |
| ; CHECK-LABEL: @trip1_i8( | |
| ; CHECK-NEXT: entry: | |
| ; CHECK-NEXT: br label [[FOR_BODY:%.*]] | |
| ; CHECK: for.body: | |
| ; CHECK-NEXT: [[I_08:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_BODY]] ] | |
| ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[SRC:%.*]], i64 [[I_08]] | |
| ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[ARRAYIDX]], align 1 | |
| ; CHECK-NEXT: [[MUL:%.*]] = shl i8 [[TMP0]], 1 | |
| ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i8, ptr [[DST:%.*]], i64 [[I_08]] | |
| ; CHECK-NEXT: [[TMP1:%.*]] = load i8, ptr [[ARRAYIDX1]], align 1 | |
| ; CHECK-NEXT: [[ADD:%.*]] = add i8 [[MUL]], [[TMP1]] | |
| ; CHECK-NEXT: store i8 [[ADD]], ptr [[ARRAYIDX1]], align 1 | |
| ; CHECK-NEXT: [[INC]] = add nuw nsw i64 [[I_08]], 1 | |
| ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INC]], 1 | |
| ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_END:%.*]], label [[FOR_BODY]] | |
| ; CHECK: for.end: | |
| ; CHECK-NEXT: ret void | |
| ; | |
| entry: | |
| br label %for.body | |
| for.body: | |
| %i.08 = phi i64 [ 0, %entry ], [ %inc, %for.body ] | |
| %arrayidx = getelementptr inbounds i8, ptr %src, i64 %i.08 | |
| %0 = load i8, ptr %arrayidx, align 1 | |
| %mul = shl i8 %0, 1 | |
| %arrayidx1 = getelementptr inbounds i8, ptr %dst, i64 %i.08 | |
| %1 = load i8, ptr %arrayidx1, align 1 | |
| %add = add i8 %mul, %1 | |
| store i8 %add, ptr %arrayidx1, align 1 | |
| %inc = add nuw nsw i64 %i.08, 1 | |
| %exitcond.not = icmp eq i64 %inc, 1 | |
| br i1 %exitcond.not, label %for.end, label %for.body | |
| for.end: | |
| ret void | |
| } | |
| define void @trip3_i8(ptr noalias nocapture noundef %dst, ptr noalias nocapture noundef readonly %src) #0 { | |
| ; CHECK-LABEL: @trip3_i8( | |
| ; CHECK-NEXT: entry: | |
| ; CHECK-NEXT: br label [[FOR_BODY:%.*]] | |
| ; CHECK: for.body: | |
| ; CHECK-NEXT: [[I_08:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_BODY]] ] | |
| ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[DST:%.*]], i64 [[I_08]] | |
| ; CHECK-NEXT: [[TMP15:%.*]] = load i8, ptr [[ARRAYIDX]], align 1 | |
| ; CHECK-NEXT: [[MUL:%.*]] = shl i8 [[TMP15]], 1 | |
| ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i8, ptr [[DST1:%.*]], i64 [[I_08]] | |
| ; CHECK-NEXT: [[TMP16:%.*]] = load i8, ptr [[ARRAYIDX1]], align 1 | |
| ; CHECK-NEXT: [[ADD:%.*]] = add i8 [[MUL]], [[TMP16]] | |
| ; CHECK-NEXT: store i8 [[ADD]], ptr [[ARRAYIDX1]], align 1 | |
| ; CHECK-NEXT: [[INC]] = add nuw nsw i64 [[I_08]], 1 | |
| ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INC]], 3 | |
| ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_END:%.*]], label [[FOR_BODY]] | |
| ; CHECK: for.end: | |
| ; CHECK-NEXT: ret void | |
| ; | |
| entry: | |
| br label %for.body | |
| for.body: | |
| %i.08 = phi i64 [ 0, %entry ], [ %inc, %for.body ] | |
| %arrayidx = getelementptr inbounds i8, ptr %src, i64 %i.08 | |
| %0 = load i8, ptr %arrayidx, align 1 | |
| %mul = shl i8 %0, 1 | |
| %arrayidx1 = getelementptr inbounds i8, ptr %dst, i64 %i.08 | |
| %1 = load i8, ptr %arrayidx1, align 1 | |
| %add = add i8 %mul, %1 | |
| store i8 %add, ptr %arrayidx1, align 1 | |
| %inc = add nuw nsw i64 %i.08, 1 | |
| %exitcond.not = icmp eq i64 %inc, 3 | |
| br i1 %exitcond.not, label %for.end, label %for.body | |
| for.end: | |
| ret void | |
| } | |
| define void @trip5_i8(ptr noalias nocapture noundef %dst, ptr noalias nocapture noundef readonly %src) #0 { | |
| ; CHECK-LABEL: @trip5_i8( | |
| ; CHECK-NEXT: entry: | |
| ; CHECK-NEXT: br label [[FOR_BODY:%.*]] | |
| ; CHECK: for.body: | |
| ; CHECK-NEXT: [[I_08:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_BODY]] ] | |
| ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[DST:%.*]], i64 [[I_08]] | |
| ; CHECK-NEXT: [[TMP15:%.*]] = load i8, ptr [[ARRAYIDX]], align 1 | |
| ; CHECK-NEXT: [[MUL:%.*]] = shl i8 [[TMP15]], 1 | |
| ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i8, ptr [[DST1:%.*]], i64 [[I_08]] | |
| ; CHECK-NEXT: [[TMP16:%.*]] = load i8, ptr [[ARRAYIDX1]], align 1 | |
| ; CHECK-NEXT: [[ADD:%.*]] = add i8 [[MUL]], [[TMP16]] | |
| ; CHECK-NEXT: store i8 [[ADD]], ptr [[ARRAYIDX1]], align 1 | |
| ; CHECK-NEXT: [[INC]] = add nuw nsw i64 [[I_08]], 1 | |
| ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INC]], 5 | |
| ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_END:%.*]], label [[FOR_BODY]] | |
| ; CHECK: for.end: | |
| ; CHECK-NEXT: ret void | |
| ; | |
| entry: | |
| br label %for.body | |
| for.body: | |
| %i.08 = phi i64 [ 0, %entry ], [ %inc, %for.body ] | |
| %arrayidx = getelementptr inbounds i8, ptr %src, i64 %i.08 | |
| %0 = load i8, ptr %arrayidx, align 1 | |
| %mul = shl i8 %0, 1 | |
| %arrayidx1 = getelementptr inbounds i8, ptr %dst, i64 %i.08 | |
| %1 = load i8, ptr %arrayidx1, align 1 | |
| %add = add i8 %mul, %1 | |
| store i8 %add, ptr %arrayidx1, align 1 | |
| %inc = add nuw nsw i64 %i.08, 1 | |
| %exitcond.not = icmp eq i64 %inc, 5 | |
| br i1 %exitcond.not, label %for.end, label %for.body | |
| for.end: | |
| ret void | |
| } | |
| define void @trip8_i8(ptr noalias nocapture noundef %dst, ptr noalias nocapture noundef readonly %src) #0 { | |
| ; CHECK-LABEL: @trip8_i8( | |
| ; CHECK-NEXT: entry: | |
| ; CHECK-NEXT: br label [[VECTOR_PH:%.*]] | |
| ; CHECK: vector.ph: | |
| ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] | |
| ; CHECK: vector.body: | |
| ; CHECK-NEXT: [[VP_OP_LOAD:%.*]] = call <vscale x 8 x i8> @llvm.vp.load.nxv8i8.p0(ptr align 1 [[SRC:%.*]], <vscale x 8 x i1> splat (i1 true), i32 8) | |
| ; CHECK-NEXT: [[TMP0:%.*]] = shl <vscale x 8 x i8> [[VP_OP_LOAD]], splat (i8 1) | |
| ; CHECK-NEXT: [[VP_OP_LOAD1:%.*]] = call <vscale x 8 x i8> @llvm.vp.load.nxv8i8.p0(ptr align 1 [[DST:%.*]], <vscale x 8 x i1> splat (i1 true), i32 8) | |
| ; CHECK-NEXT: [[TMP1:%.*]] = add <vscale x 8 x i8> [[TMP0]], [[VP_OP_LOAD1]] | |
| ; CHECK-NEXT: call void @llvm.vp.store.nxv8i8.p0(<vscale x 8 x i8> [[TMP1]], ptr align 1 [[DST]], <vscale x 8 x i1> splat (i1 true), i32 8) | |
| ; CHECK-NEXT: br label [[MIDDLE_BLOCK:%.*]] | |
| ; CHECK: middle.block: | |
| ; CHECK-NEXT: br label [[FOR_BODY:%.*]] | |
| ; CHECK: for.end: | |
| ; CHECK-NEXT: ret void | |
| ; | |
| entry: | |
| br label %for.body | |
| for.body: | |
| %i.08 = phi i64 [ 0, %entry ], [ %inc, %for.body ] | |
| %arrayidx = getelementptr inbounds i8, ptr %src, i64 %i.08 | |
| %0 = load i8, ptr %arrayidx, align 1 | |
| %mul = shl i8 %0, 1 | |
| %arrayidx1 = getelementptr inbounds i8, ptr %dst, i64 %i.08 | |
| %1 = load i8, ptr %arrayidx1, align 1 | |
| %add = add i8 %mul, %1 | |
| store i8 %add, ptr %arrayidx1, align 1 | |
| %inc = add nuw nsw i64 %i.08, 1 | |
| %exitcond.not = icmp eq i64 %inc, 8 | |
| br i1 %exitcond.not, label %for.end, label %for.body | |
| for.end: | |
| ret void | |
| } | |
| define void @trip16_i8(ptr noalias nocapture noundef %dst, ptr noalias nocapture noundef readonly %src) #0 { | |
| ; CHECK-LABEL: @trip16_i8( | |
| ; CHECK-NEXT: entry: | |
| ; CHECK-NEXT: br label [[VECTOR_PH:%.*]] | |
| ; CHECK: vector.ph: | |
| ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] | |
| ; CHECK: vector.body: | |
| ; CHECK-NEXT: [[VP_OP_LOAD:%.*]] = call <vscale x 8 x i8> @llvm.vp.load.nxv8i8.p0(ptr align 1 [[SRC:%.*]], <vscale x 8 x i1> splat (i1 true), i32 16) | |
| ; CHECK-NEXT: [[TMP6:%.*]] = shl <vscale x 8 x i8> [[VP_OP_LOAD]], splat (i8 1) | |
| ; CHECK-NEXT: [[VP_OP_LOAD1:%.*]] = call <vscale x 8 x i8> @llvm.vp.load.nxv8i8.p0(ptr align 1 [[DST:%.*]], <vscale x 8 x i1> splat (i1 true), i32 16) | |
| ; CHECK-NEXT: [[TMP11:%.*]] = add <vscale x 8 x i8> [[TMP6]], [[VP_OP_LOAD1]] | |
| ; CHECK-NEXT: call void @llvm.vp.store.nxv8i8.p0(<vscale x 8 x i8> [[TMP11]], ptr align 1 [[DST]], <vscale x 8 x i1> splat (i1 true), i32 16) | |
| ; CHECK-NEXT: br label [[MIDDLE_BLOCK:%.*]] | |
| ; CHECK: middle.block: | |
| ; CHECK-NEXT: br label [[FOR_BODY:%.*]] | |
| ; CHECK: for.end: | |
| ; CHECK-NEXT: ret void | |
| ; | |
| entry: | |
| br label %for.body | |
| for.body: | |
| %i.08 = phi i64 [ 0, %entry ], [ %inc, %for.body ] | |
| %arrayidx = getelementptr inbounds i8, ptr %src, i64 %i.08 | |
| %0 = load i8, ptr %arrayidx, align 1 | |
| %mul = shl i8 %0, 1 | |
| %arrayidx1 = getelementptr inbounds i8, ptr %dst, i64 %i.08 | |
| %1 = load i8, ptr %arrayidx1, align 1 | |
| %add = add i8 %mul, %1 | |
| store i8 %add, ptr %arrayidx1, align 1 | |
| %inc = add nuw nsw i64 %i.08, 1 | |
| %exitcond.not = icmp eq i64 %inc, 16 | |
| br i1 %exitcond.not, label %for.end, label %for.body | |
| for.end: | |
| ret void | |
| } | |
| define void @trip32_i8(ptr noalias nocapture noundef %dst, ptr noalias nocapture noundef readonly %src) #0 { | |
| ; CHECK-LABEL: @trip32_i8( | |
| ; CHECK-NEXT: entry: | |
| ; CHECK-NEXT: br label [[VECTOR_PH:%.*]] | |
| ; CHECK: vector.ph: | |
| ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] | |
| ; CHECK: vector.body: | |
| ; CHECK-NEXT: [[VP_OP_LOAD:%.*]] = call <vscale x 16 x i8> @llvm.vp.load.nxv16i8.p0(ptr align 1 [[SRC:%.*]], <vscale x 16 x i1> splat (i1 true), i32 32) | |
| ; CHECK-NEXT: [[TMP6:%.*]] = shl <vscale x 16 x i8> [[VP_OP_LOAD]], splat (i8 1) | |
| ; CHECK-NEXT: [[VP_OP_LOAD1:%.*]] = call <vscale x 16 x i8> @llvm.vp.load.nxv16i8.p0(ptr align 1 [[DST:%.*]], <vscale x 16 x i1> splat (i1 true), i32 32) | |
| ; CHECK-NEXT: [[TMP11:%.*]] = add <vscale x 16 x i8> [[TMP6]], [[VP_OP_LOAD1]] | |
| ; CHECK-NEXT: call void @llvm.vp.store.nxv16i8.p0(<vscale x 16 x i8> [[TMP11]], ptr align 1 [[DST]], <vscale x 16 x i1> splat (i1 true), i32 32) | |
| ; CHECK-NEXT: br label [[MIDDLE_BLOCK:%.*]] | |
| ; CHECK: middle.block: | |
| ; CHECK-NEXT: br label [[FOR_BODY:%.*]] | |
| ; CHECK: for.end: | |
| ; CHECK-NEXT: ret void | |
| ; | |
| entry: | |
| br label %for.body | |
| for.body: | |
| %i.08 = phi i64 [ 0, %entry ], [ %inc, %for.body ] | |
| %arrayidx = getelementptr inbounds i8, ptr %src, i64 %i.08 | |
| %0 = load i8, ptr %arrayidx, align 1 | |
| %mul = shl i8 %0, 1 | |
| %arrayidx1 = getelementptr inbounds i8, ptr %dst, i64 %i.08 | |
| %1 = load i8, ptr %arrayidx1, align 1 | |
| %add = add i8 %mul, %1 | |
| store i8 %add, ptr %arrayidx1, align 1 | |
| %inc = add nuw nsw i64 %i.08, 1 | |
| %exitcond.not = icmp eq i64 %inc, 32 | |
| br i1 %exitcond.not, label %for.end, label %for.body | |
| for.end: | |
| ret void | |
| } | |
| define void @trip24_i8(ptr noalias nocapture noundef %dst, ptr noalias nocapture noundef readonly %src) #0 { | |
| ; CHECK-LABEL: @trip24_i8( | |
| ; CHECK-NEXT: entry: | |
| ; CHECK-NEXT: br label [[VECTOR_PH:%.*]] | |
| ; CHECK: vector.ph: | |
| ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] | |
| ; CHECK: vector.body: | |
| ; CHECK-NEXT: [[VP_OP_LOAD:%.*]] = call <vscale x 16 x i8> @llvm.vp.load.nxv16i8.p0(ptr align 1 [[SRC:%.*]], <vscale x 16 x i1> splat (i1 true), i32 24) | |
| ; CHECK-NEXT: [[TMP6:%.*]] = shl <vscale x 16 x i8> [[VP_OP_LOAD]], splat (i8 1) | |
| ; CHECK-NEXT: [[VP_OP_LOAD1:%.*]] = call <vscale x 16 x i8> @llvm.vp.load.nxv16i8.p0(ptr align 1 [[DST:%.*]], <vscale x 16 x i1> splat (i1 true), i32 24) | |
| ; CHECK-NEXT: [[TMP7:%.*]] = add <vscale x 16 x i8> [[TMP6]], [[VP_OP_LOAD1]] | |
| ; CHECK-NEXT: call void @llvm.vp.store.nxv16i8.p0(<vscale x 16 x i8> [[TMP7]], ptr align 1 [[DST]], <vscale x 16 x i1> splat (i1 true), i32 24) | |
| ; CHECK-NEXT: br label [[MIDDLE_BLOCK:%.*]] | |
| ; CHECK: middle.block: | |
| ; CHECK-NEXT: br label [[FOR_BODY:%.*]] | |
| ; CHECK: for.end: | |
| ; CHECK-NEXT: ret void | |
| ; | |
| entry: | |
| br label %for.body | |
| for.body: | |
| %i.08 = phi i64 [ 0, %entry ], [ %inc, %for.body ] | |
| %arrayidx = getelementptr inbounds i8, ptr %src, i64 %i.08 | |
| %0 = load i8, ptr %arrayidx, align 1 | |
| %mul = shl i8 %0, 1 | |
| %arrayidx1 = getelementptr inbounds i8, ptr %dst, i64 %i.08 | |
| %1 = load i8, ptr %arrayidx1, align 1 | |
| %add = add i8 %mul, %1 | |
| store i8 %add, ptr %arrayidx1, align 1 | |
| %inc = add nuw nsw i64 %i.08, 1 | |
| %exitcond.not = icmp eq i64 %inc, 24 | |
| br i1 %exitcond.not, label %for.end, label %for.body | |
| for.end: | |
| ret void | |
| } | |
| define void @const_tc_with_predicated_store(i1 %c1, i1 %c2, i1 %c3, ptr %dst) #1 { | |
| ; CHECK-LABEL: @const_tc_with_predicated_store( | |
| ; CHECK-NEXT: entry: | |
| ; CHECK-NEXT: br label [[VECTOR_PH:%.*]] | |
| ; CHECK: vector.ph: | |
| ; CHECK-NEXT: [[BROADCAST_SPLATINSERT1:%.*]] = insertelement <vscale x 4 x i1> poison, i1 [[C2:%.*]], i64 0 | |
| ; CHECK-NEXT: [[BROADCAST_SPLAT2:%.*]] = shufflevector <vscale x 4 x i1> [[BROADCAST_SPLATINSERT1]], <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: [[BROADCAST_SPLATINSERT3:%.*]] = insertelement <vscale x 4 x i1> poison, i1 [[C1:%.*]], i64 0 | |
| ; CHECK-NEXT: [[BROADCAST_SPLAT4:%.*]] = shufflevector <vscale x 4 x i1> [[BROADCAST_SPLATINSERT3]], <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: [[TMP12:%.*]] = xor <vscale x 4 x i1> [[BROADCAST_SPLAT4]], splat (i1 true) | |
| ; CHECK-NEXT: [[TMP1:%.*]] = xor <vscale x 4 x i1> [[BROADCAST_SPLAT2]], splat (i1 true) | |
| ; CHECK-NEXT: [[TMP13:%.*]] = select <vscale x 4 x i1> [[TMP12]], <vscale x 4 x i1> [[TMP1]], <vscale x 4 x i1> zeroinitializer | |
| ; CHECK-NEXT: [[TMP2:%.*]] = or <vscale x 4 x i1> [[TMP13]], [[BROADCAST_SPLAT4]] | |
| ; CHECK-NEXT: [[PREDPHI:%.*]] = select i1 [[C1]], <vscale x 4 x float> splat (float 1.000000e+00), <vscale x 4 x float> zeroinitializer | |
| ; CHECK-NEXT: [[BROADCAST_SPLATINSERT4:%.*]] = insertelement <vscale x 4 x i1> poison, i1 [[C3:%.*]], i64 0 | |
| ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 4 x i1> [[BROADCAST_SPLATINSERT4]], <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer | |
| ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] | |
| ; CHECK: vector.body: | |
| ; CHECK-NEXT: [[TMP6:%.*]] = call <vscale x 4 x i1> @llvm.vp.merge.nxv4i1(<vscale x 4 x i1> splat (i1 true), <vscale x 4 x i1> [[TMP2]], <vscale x 4 x i1> zeroinitializer, i32 57) | |
| ; CHECK-NEXT: [[TMP10:%.*]] = select <vscale x 4 x i1> [[TMP6]], <vscale x 4 x i1> [[BROADCAST_SPLAT]], <vscale x 4 x i1> zeroinitializer | |
| ; CHECK-NEXT: [[PREDPHI5:%.*]] = select <vscale x 4 x i1> [[TMP10]], <vscale x 4 x float> [[PREDPHI]], <vscale x 4 x float> splat (float 2.000000e+00) | |
| ; CHECK-NEXT: call void @llvm.vp.store.nxv4f32.p0(<vscale x 4 x float> [[PREDPHI5]], ptr align 4 [[DST:%.*]], <vscale x 4 x i1> splat (i1 true), i32 57) | |
| ; CHECK-NEXT: br label [[MIDDLE_BLOCK:%.*]] | |
| ; CHECK: middle.block: | |
| ; CHECK-NEXT: br label [[EXIT:%.*]] | |
| ; CHECK: exit: | |
| ; CHECK-NEXT: ret void | |
| ; | |
| entry: | |
| br label %header | |
| header: | |
| %iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ] | |
| br i1 %c1, label %if.else1, label %if.then | |
| if.then: | |
| br i1 %c2, label %if.else2, label %if.else1 | |
| if.else1: | |
| %phi1 = phi float [ 0.0, %if.then ], [ 1.0, %header ] | |
| br i1 %c3, label %latch, label %if.else2 | |
| if.else2: | |
| br label %latch | |
| latch: | |
| %phi = phi float [ %phi1, %if.else1 ], [ 2.0, %if.else2 ] | |
| %gep = getelementptr float, ptr %dst, i64 %iv | |
| store float %phi, ptr %gep, align 4 | |
| %iv.next = add i64 %iv, 1 | |
| %ec = icmp eq i64 %iv, 56 | |
| br i1 %ec, label %exit, label %header | |
| exit: | |
| ret void | |
| } | |
| attributes #0 = { "target-features"="+v,+d" vscale_range(2, 1024) } | |
| attributes #1 = { vscale_range(16, 1024) "target-features"="+v" } | |
| ; This is a non-power-of-2 low trip count, so we will try to tail-fold this. But | |
| ; the reduction is a multiply which is only legal for fixed-length VFs. But | |
| ; fixed-length VFs aren't legal for the default tail-folding style | |
| ; data-with-evl, so make sure we gracefully fall back to data-without-lane-mask. | |
| define i8 @mul_non_pow_2_low_trip_count(ptr noalias %a) { | |
| ; CHECK-LABEL: @mul_non_pow_2_low_trip_count( | |
| ; CHECK-NEXT: entry: | |
| ; CHECK-NEXT: br label [[VECTOR_PH:%.*]] | |
| ; CHECK: vector.ph: | |
| ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] | |
| ; CHECK: vector.body: | |
| ; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <8 x i8>, ptr [[TMP0:%.*]], align 1 | |
| ; CHECK-NEXT: [[TMP1:%.*]] = mul <8 x i8> [[WIDE_LOAD]], <i8 2, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1> | |
| ; CHECK-NEXT: br label [[MIDDLE_BLOCK:%.*]] | |
| ; CHECK: middle.block: | |
| ; CHECK-NEXT: [[TMP3:%.*]] = call i8 @llvm.vector.reduce.mul.v8i8(<8 x i8> [[TMP1]]) | |
| ; CHECK-NEXT: br label [[SCALAR_PH:%.*]] | |
| ; CHECK: scalar.ph: | |
| ; CHECK-NEXT: br label [[FOR_BODY:%.*]] | |
| ; CHECK: for.body: | |
| ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 8, [[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[FOR_BODY]] ] | |
| ; CHECK-NEXT: [[RDX:%.*]] = phi i8 [ [[TMP3]], [[SCALAR_PH]] ], [ [[MUL:%.*]], [[FOR_BODY]] ] | |
| ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr [[TMP0]], i64 [[IV]] | |
| ; CHECK-NEXT: [[TMP5:%.*]] = load i8, ptr [[GEP]], align 1 | |
| ; CHECK-NEXT: [[MUL]] = mul i8 [[TMP5]], [[RDX]] | |
| ; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1 | |
| ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[IV_NEXT]], 10 | |
| ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_END:%.*]], label [[FOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]] | |
| ; CHECK: for.end: | |
| ; CHECK-NEXT: [[MUL_LCSSA:%.*]] = phi i8 [ [[MUL]], [[FOR_BODY]] ] | |
| ; CHECK-NEXT: ret i8 [[MUL_LCSSA]] | |
| ; | |
| entry: | |
| br label %for.body | |
| for.body: | |
| %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] | |
| %rdx = phi i8 [ 2, %entry ], [ %mul, %for.body ] | |
| %gep = getelementptr i8, ptr %a, i64 %iv | |
| %0 = load i8, ptr %gep | |
| %mul = mul i8 %0, %rdx | |
| %iv.next = add i64 %iv, 1 | |
| %exitcond.not = icmp eq i64 %iv.next, 10 | |
| br i1 %exitcond.not, label %for.end, label %for.body | |
| for.end: | |
| ret i8 %mul | |
| } |