[llvm] [RISCV][GISEL] Legalize G_EXTRACT_SUBVECTOR (PR #109426)
Michael Maitland via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 10:57:29 PDT 2024
================
@@ -3666,6 +3666,63 @@ LegalizerHelper::bitcastConcatVector(MachineInstr &MI, unsigned TypeIdx,
return Legalized;
}
+/// This attempts to bitcast G_EXTRACT_SUBVECTOR to CastTy.
+///
+/// <vscale x 8 x i1> = G_EXTRACT_SUBVECTOR <vscale x 16 x i1>, N
+///
+/// ===>
+///
+/// <vscale x 2 x i1> = G_BITCAST <vscale x 16 x i1>
+/// <vscale x 1 x i8> = G_EXTRACT_SUBVECTOR <vscale x 2 x i1>, N / 8
+/// <vscale x 8 x i1> = G_BITCAST <vscale x 1 x i8>
+LegalizerHelper::LegalizeResult
+LegalizerHelper::bitcastExtractSubvector(MachineInstr &MI, unsigned TypeIdx,
+ LLT CastTy) {
+ auto ES = dyn_cast<GExtractSubvector>(&MI);
+ if (!ES)
+ return UnableToLegalize;
+
+ if (!CastTy.isVector())
+ return UnableToLegalize;
+
+ if (TypeIdx != 0)
+ return UnableToLegalize;
+
+ Register Dst = ES->getReg(0);
+ Register Src = ES->getSrcVec();
+ uint64_t Idx = ES->getIndexImm();
+
+ MachineRegisterInfo &MRI = *MIRBuilder.getMRI();
+
+ LLT DstTy = MRI.getType(Dst);
+ LLT SrcTy = MRI.getType(Src);
+ ElementCount DstTyEC = DstTy.getElementCount();
+ ElementCount SrcTyEC = SrcTy.getElementCount();
+ auto DstTyMinElts = DstTyEC.getKnownMinValue();
+ auto SrcTyMinElts = SrcTyEC.getKnownMinValue();
+
+ if (DstTy == CastTy)
+ return Legalized;
+
+ auto AdjustAmt = CastTy.getScalarType().getSizeInBits();
+ if (DstTyMinElts < AdjustAmt || SrcTyMinElts < AdjustAmt)
----------------
michaelmaitland wrote:
removed.
https://github.com/llvm/llvm-project/pull/109426
More information about the llvm-commits
mailing list