[llvm] [LV][EVL] Support cast instruction with EVL-vectorization (PR #108351)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 19:22:29 PST 2024
================
@@ -962,22 +962,35 @@ void VPWidenIntrinsicRecipe::execute(VPTransformState &State) {
// Use vector version of the intrinsic.
Module *M = State.Builder.GetInsertBlock()->getModule();
+ bool IsVPIntrinsic = VPIntrinsic::isVPIntrinsic(VectorIntrinsicID);
Function *VectorF =
- Intrinsic::getOrInsertDeclaration(M, VectorIntrinsicID, TysForDecl);
- assert(VectorF && "Can't retrieve vector intrinsic.");
+ IsVPIntrinsic
+ ? VPIntrinsic::getOrInsertDeclarationForParams(M, VectorIntrinsicID,
+ TysForDecl[0], Args)
+ : Intrinsic::getOrInsertDeclaration(M, VectorIntrinsicID, TysForDecl);
+ assert(VectorF &&
+ "Can't retrieve vector intrinsic or vector-predication intrinsics.");
- auto *CI = cast_or_null<CallInst>(getUnderlyingValue());
SmallVector<OperandBundleDef, 1> OpBundles;
- if (CI)
- CI->getOperandBundlesAsDefs(OpBundles);
+ if (!IsVPIntrinsic) {
+ if (auto *CI = cast_or_null<CallInst>(getUnderlyingValue()))
+ CI->getOperandBundlesAsDefs(OpBundles);
+ }
- CallInst *V = State.Builder.CreateCall(VectorF, Args, OpBundles);
+ Instruction *V = State.Builder.CreateCall(VectorF, Args, OpBundles);
- setFlags(V);
+ if (IsVPIntrinsic) {
+ // Currently vp-intrinsics only accept FMF flags. llvm.vp.uitofp will get
+ // Flags of OperationType::NonNegOp && OperationType::FPMathOp.
+ if (isa<FPMathOperator>(V) && VectorIntrinsicID != Intrinsic::vp_uitofp)
+ setFlags(V);
----------------
LiqinWeng wrote:
> I have a question here. Will setFlags really function as we expect if we don't pass the underlying instruction into the recipe? This PR also seems to lack corresponding test cases to verify whether the FMF has been correctly set.
In the previous commit I pass the underlying instruction. At present, it seems that the underlying instruction information needs to be passed when setting metedata and flag. I am not sure about the flags of VP intrinsics, and they do not seem to correspond to non-vp intrinsics. For example, uitofp has the nneg IR flags, but llvm.vp.uitofp seems no this flag. I'm not sure if I understood something wrong. :) . And can we temporarily not set flag and resubmit a new ptach to deal with it?
https://github.com/llvm/llvm-project/pull/108351
More information about the llvm-commits
mailing list