Skip to content

Commit f788c9c

Browse files
committed
rebase and fix the comments
1 parent e51d18b commit f788c9c

File tree

4 files changed

+35
-41
lines changed

4 files changed

+35
-41
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,19 +1415,15 @@ void VPWidenEVLRecipe::execute(VPTransformState &State) {
14151415

14161416
IRBuilderBase &BuilderIR = State.Builder;
14171417
VectorBuilder Builder(BuilderIR);
1418+
14181419
Value *Mask = BuilderIR.CreateVectorSplat(State.VF, BuilderIR.getTrue());
14191420
Builder.setMask(Mask).setEVL(State.get(getEVL(), /*NeedsScalar=*/true));
1420-
1421-
VectorType *DataType = VectorType::get(Type::getInt1Ty(Ctx), State.VF);
1422-
1423-
Value *VPInst = Builder.createVectorInstruction(Opcode, DataType,
1421+
VectorType *RetType = VectorType::get(Type::getInt1Ty(Ctx), State.VF);
1422+
Value *VPInst = Builder.createVectorInstruction(Opcode, RetType,
14241423
{Op1, Op2, Pred}, "vp.op");
1425-
// if (isa<FPMathOperator>(VPInst))
1426-
// setFlags(cast<Instruction>(VPInst));
1427-
if (VPInst) {
1428-
if (auto *VecOp = dyn_cast<CastInst>(VPInst))
1429-
VecOp->copyIRFlags(getUnderlyingInstr());
1430-
}
1424+
if (auto *VecOp = dyn_cast<CastInst>(VPInst))
1425+
VecOp->copyIRFlags(getUnderlyingInstr());
1426+
14311427
State.set(this, VPInst, 0);
14321428
State.addMetadata(VPInst,
14331429
dyn_cast_or_null<Instruction>(getUnderlyingValue()));

llvm/test/Transforms/LoopVectorize/RISCV/vectorize-force-tail-with-evl-cond-reduction.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ define i32 @cond_add(ptr %a, i64 %n, i32 %start) {
6969
; IF-EVL-INLOOP-NEXT: [[TMP17:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[TMP13]]
7070
; IF-EVL-INLOOP-NEXT: [[TMP18:%.*]] = getelementptr inbounds i32, ptr [[TMP17]], i32 0
7171
; IF-EVL-INLOOP-NEXT: [[VP_OP_LOAD:%.*]] = call <vscale x 4 x i32> @llvm.vp.load.nxv4i32.p0(ptr align 4 [[TMP18]], <vscale x 4 x i1> shufflevector (<vscale x 4 x i1> insertelement (<vscale x 4 x i1> poison, i1 true, i64 0), <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer), i32 [[TMP12]])
72-
; IF-EVL-INLOOP-NEXT: [[TMP19:%.*]] = icmp sgt <vscale x 4 x i32> [[VP_OP_LOAD]], shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 3, i64 0), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer)
72+
; IF-EVL-INLOOP-NEXT: [[TMP19:%.*]] = call <vscale x 4 x i1> @llvm.vp.icmp.nxv4i32(<vscale x 4 x i32> %vp.op.load, <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 3, i64 0), <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer), metadata !"sgt", <vscale x 4 x i1> shufflevector (<vscale x 4 x i1> insertelement (<vscale x 4 x i1> poison, i1 true, i64 0), <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer), i32 %9)
7373
; IF-EVL-INLOOP-NEXT: [[TMP20:%.*]] = call <vscale x 4 x i32> @llvm.vp.select.nxv4i32(<vscale x 4 x i1> [[TMP19]], <vscale x 4 x i32> [[VP_OP_LOAD]], <vscale x 4 x i32> zeroinitializer, i32 [[TMP12]])
7474
; IF-EVL-INLOOP-NEXT: [[TMP21:%.*]] = call i32 @llvm.vp.reduce.add.nxv4i32(i32 0, <vscale x 4 x i32> [[TMP20]], <vscale x 4 x i1> shufflevector (<vscale x 4 x i1> insertelement (<vscale x 4 x i1> poison, i1 true, i64 0), <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer), i32 [[TMP12]])
7575
; IF-EVL-INLOOP-NEXT: [[TMP22]] = add i32 [[TMP21]], [[VEC_PHI]]

llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-cmp-intrinsics.ll

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,24 @@ define void @vp_icmp(ptr noalias %a, ptr noalias %b, ptr noalias %c, i64 %N) {
4040
; IF-EVL-NEXT: }
4141

4242
entry:
43-
%cmp12 = icmp sgt i64 %N, 0
44-
br i1 %cmp12, label %for.body, label %for.cond.cleanup
43+
br label %loop
4544

46-
for.cond.cleanup: ; preds = %for.body, %entry
47-
ret void
48-
49-
for.body: ; preds = %entry, %for.body
50-
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
51-
%arrayidx = getelementptr inbounds i32, ptr %b, i64 %indvars.iv
45+
loop:
46+
%iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]
47+
%arrayidx = getelementptr inbounds i32, ptr %b, i64 %iv
5248
%0 = load i32, ptr %arrayidx, align 4
53-
%arrayidx3 = getelementptr inbounds i32, ptr %c, i64 %indvars.iv
54-
%1 = load i32, ptr %arrayidx3, align 4
49+
%gep = getelementptr inbounds i32, ptr %c, i64 %iv
50+
%1 = load i32, ptr %gep, align 4
5551
%cmp4 = icmp sgt i32 %0, %1
5652
%conv5 = zext i1 %cmp4 to i32
57-
%arrayidx7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
53+
%arrayidx7 = getelementptr inbounds i32, ptr %a, i64 %iv
5854
store i32 %conv5, ptr %arrayidx7, align 4
59-
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
60-
%exitcond.not = icmp eq i64 %indvars.iv.next, %N
61-
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
55+
%iv.next = add nuw nsw i64 %iv, 1
56+
%exitcond.not = icmp eq i64 %iv.next, %N
57+
br i1 %exitcond.not, label %exit, label %loop
58+
59+
exit:
60+
ret void
6261
}
6362

6463
define void @vp_fcmp(ptr noalias %a, ptr noalias %b, ptr noalias %c, i64 %N) {
@@ -96,23 +95,22 @@ define void @vp_fcmp(ptr noalias %a, ptr noalias %b, ptr noalias %c, i64 %N) {
9695
; IF-EVL-NEXT: }
9796

9897
entry:
99-
%cmp13 = icmp sgt i64 %N, 0
100-
br i1 %cmp13, label %for.body, label %for.cond.cleanup
98+
br label %loop
10199

102-
for.cond.cleanup:
103-
ret void
104-
105-
for.body:
106-
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
107-
%arrayidx = getelementptr inbounds float, ptr %b, i64 %indvars.iv
100+
loop:
101+
%iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]
102+
%arrayidx = getelementptr inbounds float, ptr %b, i64 %iv
108103
%0 = load float, ptr %arrayidx, align 4
109-
%arrayidx3 = getelementptr inbounds float, ptr %c, i64 %indvars.iv
110-
%1 = load float, ptr %arrayidx3, align 4
104+
%gep = getelementptr inbounds float, ptr %c, i64 %iv
105+
%1 = load float, ptr %gep, align 4
111106
%cmp4 = fcmp ogt float %0, %1
112107
%conv6 = uitofp i1 %cmp4 to float
113-
%arrayidx8 = getelementptr inbounds float, ptr %a, i64 %indvars.iv
108+
%arrayidx8 = getelementptr inbounds float, ptr %a, i64 %iv
114109
store float %conv6, ptr %arrayidx8, align 4
115-
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
116-
%exitcond.not = icmp eq i64 %indvars.iv.next, %N
117-
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
118-
}
110+
%iv.next = add nuw nsw i64 %iv, 1
111+
%exitcond.not = icmp eq i64 %iv.next, %N
112+
br i1 %exitcond.not, label %exit, label %loop
113+
114+
exit:
115+
ret void
116+
}

llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-select-intrinsics.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
; IF-EVL-NEXT: CLONE ir<[[GEP2:%.+]]> = getelementptr inbounds ir<%c>, vp<[[ST]]>
2828
; IF-EVL-NEXT: vp<[[PTR2:%[0-9]+]]> = vector-pointer ir<[[GEP2]]>
2929
; IF-EVL-NEXT: WIDEN ir<[[LD2:%.+]]> = vp.load vp<[[PTR2]]>, vp<[[EVL]]>
30-
; IF-EVL-NEXT: WIDEN ir<[[CMP:%.+]]> = icmp sgt ir<[[LD1]]>, ir<[[LD2]]>
30+
; IF-EVL-NEXT: WIDEN ir<[[CMP:%.+]]> = vp.icmp sgt ir<[[LD1]]>, ir<[[LD2]]>
3131
; IF-EVL-NEXT: WIDEN ir<[[SUB:%.+]]> = vp.sub ir<0>, ir<[[LD2]]>, vp<[[EVL]]>
3232
; IF-EVL-NEXT: WIDEN-INTRINSIC vp<[[SELECT:%.+]]> = call llvm.vp.select(ir<[[CMP]]>, ir<%1>, ir<%2>, vp<[[EVL]]>)
3333
; IF-EVL-NEXT: WIDEN ir<[[ADD:%.+]]> = vp.add vp<[[SELECT]]>, ir<[[LD1]]>, vp<[[EVL]]>

0 commit comments

Comments
 (0)