[llvm] [RISCV][GISEL] Legalize G_EXTRACT_SUBVECTOR (PR #109426)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 10:24:08 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())
----------------
topperc wrote:

This would be malformed IR, right?

https://github.com/llvm/llvm-project/pull/109426


More information about the llvm-commits mailing list