Skip to content

Commit 44a46a0

Browse files
[RISCV][GISEL] Add IRTranslation for insertelement with scalable vector type (#80377)
This patch is stacked on #80372, #80307, and #80306.
1 parent 66ebda4 commit 44a46a0

File tree

4 files changed

+1954
-6
lines changed

4 files changed

+1954
-6
lines changed

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2965,7 +2965,8 @@ bool IRTranslator::translateInsertElement(const User &U,
29652965
MachineIRBuilder &MIRBuilder) {
29662966
// If it is a <1 x Ty> vector, use the scalar as it is
29672967
// not a legal vector type in LLT.
2968-
if (cast<FixedVectorType>(U.getType())->getNumElements() == 1)
2968+
if (auto *FVT = dyn_cast<FixedVectorType>(U.getType());
2969+
FVT && FVT->getNumElements() == 1)
29692970
return translateCopy(U, *U.getOperand(1), MIRBuilder);
29702971

29712972
Register Res = getOrCreateVReg(U);

llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,8 +1287,8 @@ MachineIRBuilder::buildInstr(unsigned Opc, ArrayRef<DstOp> DstOps,
12871287
SrcOps[1].getLLTTy(*getMRI()) &&
12881288
"Type mismatch");
12891289
assert(SrcOps[2].getLLTTy(*getMRI()).isScalar() && "Invalid index");
1290-
assert(DstOps[0].getLLTTy(*getMRI()).getNumElements() ==
1291-
SrcOps[0].getLLTTy(*getMRI()).getNumElements() &&
1290+
assert(DstOps[0].getLLTTy(*getMRI()).getElementCount() ==
1291+
SrcOps[0].getLLTTy(*getMRI()).getElementCount() &&
12921292
"Type mismatch");
12931293
break;
12941294
}

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20729,11 +20729,11 @@ unsigned RISCVTargetLowering::getCustomCtpopCost(EVT VT,
2072920729

2073020730
bool RISCVTargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
2073120731

20732-
// GISel support is in progress or complete for G_ADD, G_SUB, G_AND, G_OR, and
20733-
// G_XOR.
20732+
// GISel support is in progress or complete for these opcodes.
2073420733
unsigned Op = Inst.getOpcode();
2073520734
if (Op == Instruction::Add || Op == Instruction::Sub ||
20736-
Op == Instruction::And || Op == Instruction::Or || Op == Instruction::Xor)
20735+
Op == Instruction::And || Op == Instruction::Or ||
20736+
Op == Instruction::Xor || Op == Instruction::InsertElement)
2073720737
return false;
2073820738

2073920739
if (Inst.getType()->isScalableTy())

0 commit comments

Comments
 (0)