Skip to content

Commit 0b3836c

Browse files
committed
[LV][EVL] Support fpext/fptrunc/fptosi/fptoui/sitofp/uitofp/inttoptr/ptrtoint of cast instruction with EVL-vectorization
1 parent a04e5ec commit 0b3836c

File tree

4 files changed

+459
-30
lines changed

4 files changed

+459
-30
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,14 +1617,14 @@ class VPWidenCastEVLRecipe : public VPWidenCastRecipe {
16171617

16181618
public:
16191619
VPWidenCastEVLRecipe(Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy,
1620-
VPValue &EVL)
1621-
: VPWidenCastRecipe(VPDef::VPWidenCastEVLSC, Opcode, Op, ResultTy) {
1620+
CastInst &UI, VPValue &EVL)
1621+
: VPWidenCastRecipe(VPDef::VPWidenCastEVLSC, Opcode, Op, ResultTy, UI) {
16221622
addOperand(&EVL);
16231623
}
16241624

16251625
VPWidenCastEVLRecipe(VPWidenCastRecipe &W, VPValue &EVL)
16261626
: VPWidenCastEVLRecipe(W.getOpcode(), W.getOperand(0), W.getResultType(),
1627-
EVL) {
1627+
*cast<CastInst>(W.getUnderlyingInstr()), EVL) {
16281628
transferFlags(W);
16291629
}
16301630

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,13 +1386,12 @@ void VPWidenCastRecipe::execute(VPTransformState &State) {
13861386

13871387
void VPWidenCastEVLRecipe::execute(VPTransformState &State) {
13881388
unsigned Opcode = getOpcode();
1389+
auto Inst = cast<CastInst>(getUnderlyingInstr());
13891390
State.setDebugLocFrom(getDebugLoc());
13901391
assert(State.UF == 1 && "Expected only UF == 1 when vectorizing with "
13911392
"explicit vector length.");
13921393

1393-
// TODO: add more cast instruction, eg: fptoint/inttofp/inttoptr/fptofp
1394-
if (Opcode == Instruction::SExt || Opcode == Instruction::ZExt ||
1395-
Opcode == Instruction::Trunc) {
1394+
if (Inst->isCast()) {
13961395
Value *SrcVal = State.get(getOperand(0), 0);
13971396
VectorType *DsType = VectorType::get(getResultType(), State.VF);
13981397

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,10 +1346,8 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
13461346
})
13471347
.Case<VPWidenCastRecipe>(
13481348
[&](VPWidenCastRecipe *W) -> VPRecipeBase * {
1349-
unsigned Opcode = W->getOpcode();
1350-
if (Opcode != Instruction::SExt &&
1351-
Opcode != Instruction::ZExt &&
1352-
Opcode != Instruction::Trunc)
1349+
auto Inst = cast<CastInst>(W->getUnderlyingInstr());
1350+
if (!Inst->isCast())
13531351
return nullptr;
13541352
return new VPWidenCastEVLRecipe(*W, EVL);
13551353
})

0 commit comments

Comments
 (0)