Skip to content

Commit ea798a7

Browse files
[RISCV][GISEL] Legalize and regbankselect vector typed G_IMPLICIT_DEF
1 parent 33cf27b commit ea798a7

File tree

4 files changed

+845
-1
lines changed

4 files changed

+845
-1
lines changed

llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,11 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
217217
ConstantActions.customFor({s64});
218218
ConstantActions.widenScalarToNextPow2(0).clampScalar(0, s32, sXLen);
219219

220+
// TODO: transform illegal vector types into legal vector type
220221
getActionDefinitionsBuilder(G_IMPLICIT_DEF)
221222
.legalFor({s32, sXLen, p0})
223+
.legalIf(typeIsLegalBoolVec(0, BoolVecTys, ST))
224+
.legalIf(typeIsLegalIntOrFPVec(0, IntOrFPVecTys, ST))
222225
.widenScalarToNextPow2(0)
223226
.clampScalar(0, s32, sXLen);
224227

llvm/lib/Target/RISCV/GISel/RISCVRegisterBankInfo.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,14 +343,20 @@ RISCVRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
343343
}
344344
case TargetOpcode::G_IMPLICIT_DEF: {
345345
Register Dst = MI.getOperand(0).getReg();
346+
LLT DstTy = MRI.getType(Dst);
347+
uint64_t DstMinSize = DstTy.getSizeInBits().getKnownMinValue();
346348
auto Mapping = GPRValueMapping;
347349
// FIXME: May need to do a better job determining when to use FPRB.
348350
// For example, the look through COPY case:
349351
// %0:_(s32) = G_IMPLICIT_DEF
350352
// %1:_(s32) = COPY %0
351353
// $f10_d = COPY %1(s32)
352354
if (anyUseOnlyUseFP(Dst, MRI, TRI))
353-
Mapping = getFPValueMapping(MRI.getType(Dst).getSizeInBits());
355+
Mapping = getFPValueMapping(DstMinSize);
356+
357+
if (DstTy.isVector())
358+
Mapping = getVRBValueMapping(DstMinSize);
359+
354360
return getInstructionMapping(DefaultMappingID, /*Cost=*/1, Mapping,
355361
NumOperands);
356362
}

0 commit comments

Comments
 (0)