[llvm] [AArch64][GlobalISel] Refactor BITCAST Legalization (PR #80505)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 08:37:51 PST 2024
================
@@ -4654,11 +4654,49 @@ LegalizerHelper::fewerElementsVector(MachineInstr &MI, unsigned TypeIdx,
return fewerElementsVectorShuffle(MI, TypeIdx, NarrowTy);
case G_FPOWI:
return fewerElementsVectorMultiEltType(GMI, NumElts, {2 /*pow*/});
+ case G_BITCAST:
+ return fewerElementsBitcast(MI, TypeIdx, NarrowTy);
default:
return UnableToLegalize;
}
}
+LegalizerHelper::LegalizeResult
+LegalizerHelper::fewerElementsBitcast(MachineInstr &MI, unsigned int TypeIdx,
+ LLT NarrowTy) {
+ assert(MI.getOpcode() == TargetOpcode::G_BITCAST &&
+ "Not a bitcast operation");
+
+ if (TypeIdx != 0)
+ return UnableToLegalize;
+
+ auto [DstReg, DstTy, SrcReg, SrcTy] = MI.getFirst2RegLLTs();
+
+ unsigned SrcScalSize = SrcTy.getScalarSizeInBits();
+ LLT SrcNarrowTy =
+ LLT::fixed_vector(NarrowTy.getSizeInBits() / SrcScalSize, SrcScalSize);
+
+ // Split the Src and Dst Reg into smaller registers
+ LLT SrcLeftoverTy;
+ SmallVector<Register> SrcVRegs, SrcLeftoverVRegs, BitcastVRegs;
+ // MIRBuilder.setInstrAndDebugLoc(MI);
+ if (!extractParts(SrcReg, SrcTy, SrcNarrowTy, SrcLeftoverTy, SrcVRegs,
----------------
chuongg3 wrote:
Do you have any recommendations on how to approach this?
Falling back to G_EXTRACT would be quite rare as there is `moreElementsToNextPow2()` before clamping the vectors, so there will not be a lot of cases where it would be falling back to G_EXTRACT when splitting up the vectors
https://github.com/llvm/llvm-project/pull/80505
More information about the llvm-commits
mailing list