@@ -2180,6 +2180,19 @@ getHalfEltSizeTwiceNumElemsVecType(CIRGenBuilderTy &builder,
2180
2180
vecTy.getSize () * 2 );
2181
2181
}
2182
2182
2183
+ static cir::VectorType
2184
+ castVecOfFPTypeToVecOfIntWithSameWidth (CIRGenBuilderTy &builder,
2185
+ cir::VectorType vecTy) {
2186
+ if (mlir::isa<cir::SingleType>(vecTy.getEltType ()))
2187
+ return cir::VectorType::get (builder.getContext (), builder.getSInt32Ty (),
2188
+ vecTy.getSize ());
2189
+ if (mlir::isa<cir::DoubleType>(vecTy.getEltType ()))
2190
+ return cir::VectorType::get (builder.getContext (), builder.getSInt64Ty (),
2191
+ vecTy.getSize ());
2192
+ llvm_unreachable (
2193
+ " Unsupported element type in getVecOfIntTypeWithSameEltWidth" );
2194
+ }
2195
+
2183
2196
// / Get integer from a mlir::Value that is an int constant or a constant op.
2184
2197
static int64_t getIntValueFromConstOp (mlir::Value val) {
2185
2198
auto constOp = mlir::cast<cir::ConstantOp>(val.getDefiningOp ());
@@ -3832,7 +3845,17 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
3832
3845
return nullptr ;
3833
3846
case NEON::BI__builtin_neon_vbsl_v:
3834
3847
case NEON::BI__builtin_neon_vbslq_v: {
3835
- llvm_unreachable (" NEON::BI__builtin_neon_vbslq_v NYI" );
3848
+ cir::VectorType bitTy = vTy;
3849
+ if (cir::isAnyFloatingPointType (bitTy.getEltType ()))
3850
+ bitTy = castVecOfFPTypeToVecOfIntWithSameWidth (builder, vTy);
3851
+ Ops[0 ] = builder.createBitcast (Ops[0 ], bitTy);
3852
+ Ops[1 ] = builder.createBitcast (Ops[1 ], bitTy);
3853
+ Ops[2 ] = builder.createBitcast (Ops[2 ], bitTy);
3854
+
3855
+ Ops[1 ] = builder.createAnd (Ops[0 ], Ops[1 ]);
3856
+ Ops[2 ] = builder.createAnd (builder.createNot (Ops[0 ]), Ops[2 ]);
3857
+ Ops[0 ] = builder.createOr (Ops[1 ], Ops[2 ]);
3858
+ return builder.createBitcast (Ops[0 ], ty);
3836
3859
}
3837
3860
case NEON::BI__builtin_neon_vfma_lane_v:
3838
3861
case NEON::BI__builtin_neon_vfmaq_lane_v: { // Only used for FP types
0 commit comments