================ @@ -2136,14 +2136,16 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { // bitcast. if (const auto *FixedSrc = dyn_cast<llvm::FixedVectorType>(SrcTy)) { if (const auto *ScalableDst = dyn_cast<llvm::ScalableVectorType>(DstTy)) { - // If we are casting a fixed i8 vector to a scalable 16 x i1 predicate + // If we are casting a fixed i8 vector to a scalable i1 predicate // vector, use a vector insert and bitcast the result. bool NeedsBitCast = false; - auto PredType = llvm::ScalableVectorType::get(Builder.getInt1Ty(), 16); llvm::Type *OrigType = DstTy; - if (ScalableDst == PredType && - FixedSrc->getElementType() == Builder.getInt8Ty()) { - DstTy = llvm::ScalableVectorType::get(Builder.getInt8Ty(), 2); + if (ScalableDst->getElementType()->isIntegerTy(1) && ---------------- sdesmalen-arm wrote:
nit: While you're touching this code, maybe refactor this whole block to remove the control flow by `NeedsBitCast`, by something like this: ``` if (const auto *FixedSrc = dyn_cast<llvm::FixedVectorType>(SrcTy)) { if (const auto *ScalableDst = dyn_cast<llvm::ScalableVectorType>(DstTy)) { llvm::Value *Zero = llvm::Constant::getNullValue(CGF.CGM.Int64Ty); if (ScalableDst->getElementType()->isIntegerTy(1) && ScalableDst->getElementCount().isKnownMultipleOf(8) && FixedSrc->getElementType()->isIntegerTy(8)) { auto InsertTy = llvm::ScalableVectorType::get( FixedSrc->getElementType(), FixedSrc->getNumElements()); llvm::Value *Insert = Builder.CreateInsertVector( InsertTy, llvm::UndefValue::get(InsertTy), Src, Zero, "cast.scalable"); return Builder.CreateBitCast(Insert, DstTy); } else if (FixedSrc->getElementType() == ScalableDst->getElementType()) return Builder.CreateInsertVector(DstTy, llvm::UndefValue::get(DstTy), Src, Zero, "cast.scalable"); } } ``` What do you think? (similar suggestion for the other case below for scalable -> fixed) https://github.com/llvm/llvm-project/pull/76548 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits