[llvm] [AArch64][GlobalISel] Bitcast and Build Illegal G_CONCAT_VECTOR Instructions (PR #96492)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 05:12:00 PDT 2024


================
@@ -3386,6 +3386,41 @@ LegalizerHelper::bitcastInsertVectorElt(MachineInstr &MI, unsigned TypeIdx,
   return UnableToLegalize;
 }
 
+LegalizerHelper::LegalizeResult
+LegalizerHelper::bitcastConcatVector(MachineInstr &MI, unsigned TypeIdx,
+                                     LLT CastTy) {
+  // Convert it to CONCAT instruction
+  auto ConcatMI = dyn_cast<GConcatVectors>(&MI);
+  if (!ConcatMI) {
+    return UnableToLegalize;
+  }
+
+  // Check if bitcast is Legal
+  auto [DstReg, DstTy, SrcReg, SrcTy] = MI.getFirst2RegLLTs();
+  LLT SrcScalTy = LLT::scalar(SrcTy.getSizeInBits());
+
+  // Check if the build vector is Legal
+  if (!LI.isLegal({TargetOpcode::G_BUILD_VECTOR, {CastTy, SrcScalTy}})) {
----------------
arsenm wrote:

The legalizer should generally do as asked, and not consider the legality of what new operations its emitting (other than for picking a possibly more optimal path). Not being legal should not cause a failure to  legalize 

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


More information about the llvm-commits mailing list