Skip to content

Commit 44ebfbd

Browse files
committed
[LV][EVL] Support fpext/fptrunc/fptosi/fptoui/sitofp/uitofp/inttoptr/ptrtoint of cast instruction with EVL-vectorization
1 parent 164862c commit 44ebfbd

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
@@ -1594,14 +1594,14 @@ class VPWidenCastEVLRecipe : public VPWidenCastRecipe {
15941594

15951595
public:
15961596
VPWidenCastEVLRecipe(Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy,
1597-
VPValue &EVL)
1598-
: VPWidenCastRecipe(VPDef::VPWidenCastEVLSC, Opcode, Op, ResultTy) {
1597+
CastInst &UI, VPValue &EVL)
1598+
: VPWidenCastRecipe(VPDef::VPWidenCastEVLSC, Opcode, Op, ResultTy, UI) {
15991599
addOperand(&EVL);
16001600
}
16011601

16021602
VPWidenCastEVLRecipe(VPWidenCastRecipe &W, VPValue &EVL)
16031603
: VPWidenCastEVLRecipe(W.getOpcode(), W.getOperand(0), W.getResultType(),
1604-
EVL) {
1604+
*cast<CastInst>(W.getUnderlyingInstr()), EVL) {
16051605
transferFlags(W);
16061606
}
16071607

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

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

13461346
void VPWidenCastEVLRecipe::execute(VPTransformState &State) {
13471347
unsigned Opcode = getOpcode();
1348+
auto Inst = cast<CastInst>(getUnderlyingInstr());
13481349
State.setDebugLocFrom(getDebugLoc());
13491350
assert(State.UF == 1 && "Expected only UF == 1 when vectorizing with "
13501351
"explicit vector length.");
13511352

1352-
// TODO: add more cast instruction, eg: fptoint/inttofp/inttoptr/fptofp
1353-
if (Opcode == Instruction::SExt || Opcode == Instruction::ZExt ||
1354-
Opcode == Instruction::Trunc) {
1353+
if (Inst->isCast()) {
13551354
Value *SrcVal = State.get(getOperand(0), 0);
13561355
VectorType *DsType = VectorType::get(getResultType(), State.VF);
13571356

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,10 +1381,8 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
13811381
})
13821382
.Case<VPWidenCastRecipe>(
13831383
[&](VPWidenCastRecipe *W) -> VPRecipeBase * {
1384-
unsigned Opcode = W->getOpcode();
1385-
if (Opcode != Instruction::SExt &&
1386-
Opcode != Instruction::ZExt &&
1387-
Opcode != Instruction::Trunc)
1384+
auto Inst = cast<CastInst>(W->getUnderlyingInstr());
1385+
if (!Inst->isCast())
13881386
return nullptr;
13891387
return new VPWidenCastEVLRecipe(*W, EVL);
13901388
})

0 commit comments

Comments
 (0)