@@ -120,18 +120,16 @@ bool RISCVCodeGenPrepare::visitAnd(BinaryOperator &BO) {
120
120
// vectorize any scalar phis that feed into a fadd reduction:
121
121
//
122
122
// loop:
123
- // %phi = phi <float> [ ..., %entry ], [ %acc, %loop]
124
- // %acc = call float @llvm.vector.reduce.fadd.nxv4f32(float %phi, <vscale x 2 x
125
- // float> %vec)
123
+ // %phi = phi <float> [ ..., %entry ], [ %acc, %loop ]
124
+ // %acc = call float @llvm.vector.reduce.fadd.nxv4f32(float %phi, <vscale x 2 x float> %vec)
126
125
//
127
126
// ->
128
127
//
129
128
// loop:
130
- // %phi = phi <vscale x 2 x float> [ ..., %entry ], [ %acc.vec, %loop]
129
+ // %phi = phi <vscale x 2 x float> [ ..., %entry ], [ %acc.vec, %loop ]
131
130
// %phi.scalar = extractelement <vscale x 2 x float> %phi, i64 0
132
- // %acc = call float @llvm.vector.reduce.fadd.nxv4f32(float %x, <vscale x 2 x
133
- // float> %vec) %acc.vec = insertelement <vscale x 2 x float> poison, float
134
- // %acc.next, i64 0
131
+ // %acc = call float @llvm.vector.reduce.fadd.nxv4f32(float %x, <vscale x 2 x float> %vec)
132
+ // %acc.vec = insertelement <vscale x 2 x float> poison, float %acc.next, i64 0
135
133
//
136
134
// Which eliminates the scalar -> vector -> scalar crossing during instruction
137
135
// selection.
@@ -140,7 +138,7 @@ bool RISCVCodeGenPrepare::visitIntrinsicInst(IntrinsicInst &I) {
140
138
return false ;
141
139
142
140
auto *PHI = dyn_cast<PHINode>(I.getOperand (0 ));
143
- if (!PHI || ! llvm::is_contained (PHI-> incoming_values (), &I) )
141
+ if (!PHI)
144
142
return false ;
145
143
146
144
Type *VecTy = I.getOperand (1 )->getType ();
@@ -157,6 +155,9 @@ bool RISCVCodeGenPrepare::visitIntrinsicInst(IntrinsicInst &I) {
157
155
Builder.SetInsertPoint (&I);
158
156
I.setOperand (0 , Builder.CreateExtractElement (VecPHI, (uint64_t )0 ));
159
157
158
+ if (PHI->hasNUses (0 ))
159
+ PHI->eraseFromParent ();
160
+
160
161
return true ;
161
162
}
162
163
0 commit comments