Skip to content

Commit 7f20e34

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

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

16011601
public:
16021602
VPWidenCastEVLRecipe(Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy,
1603-
VPValue &EVL)
1604-
: VPWidenCastRecipe(VPDef::VPWidenCastEVLSC, Opcode, Op, ResultTy) {
1603+
CastInst &UI, VPValue &EVL)
1604+
: VPWidenCastRecipe(VPDef::VPWidenCastEVLSC, Opcode, Op, ResultTy, UI) {
16051605
addOperand(&EVL);
16061606
}
16071607

16081608
VPWidenCastEVLRecipe(VPWidenCastRecipe &W, VPValue &EVL)
16091609
: VPWidenCastEVLRecipe(W.getOpcode(), W.getOperand(0), W.getResultType(),
1610-
EVL) {
1610+
*cast<CastInst>(W.getUnderlyingInstr()), EVL) {
16111611
transferFlags(W);
16121612
}
16131613

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

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

14251425
void VPWidenCastEVLRecipe::execute(VPTransformState &State) {
14261426
unsigned Opcode = getOpcode();
1427+
auto Inst = cast<CastInst>(getUnderlyingInstr());
14271428
State.setDebugLocFrom(getDebugLoc());
14281429
assert(State.UF == 1 && "Expected only UF == 1 when vectorizing with "
14291430
"explicit vector length.");
14301431

1431-
// TODO: add more cast instruction, eg: fptoint/inttofp/inttoptr/fptofp
1432-
if (Opcode == Instruction::SExt || Opcode == Instruction::ZExt ||
1433-
Opcode == Instruction::Trunc) {
1432+
if (Inst->isCast()) {
14341433
Value *SrcVal = State.get(getOperand(0), 0);
14351434
VectorType *DsType = VectorType::get(getResultType(), State.VF);
14361435

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)