[llvm] [GISel] Combine vector load followed by an extractelement (PR #72670)

Pranav Taneja via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 22:34:36 PST 2023


================
@@ -1165,6 +1165,140 @@ bool CombinerHelper::findPreIndexCandidate(GLoadStore &LdSt, Register &Addr,
   return RealUse;
 }
 
+bool CombinerHelper::matchCombineExtractedVectorLoad(MachineInstr &MI) {
+  assert(MI.getOpcode() == TargetOpcode::G_EXTRACT_VECTOR_ELT);
+
+  // Check if there is a load that defines the vector being extracted from.
+  MachineInstr *LoadMI =
+      getOpcodeDef(TargetOpcode::G_LOAD, MI.getOperand(1).getReg(), MRI);
+  if (!LoadMI)
+    return false;
+
+  Register Vector = MI.getOperand(1).getReg();
+  LLT VecEltVT = MRI.getType(Vector).getElementType();
+  LLT ResultVT = MRI.getType(MI.getOperand(0).getReg());
+
+  // Do not combine when result type and vector element type are not the same.
----------------
prtaneja wrote:

In that case, Should I remove this check for the time being and leave a fixme comment (in case your suspicion materializes in future) instead? 
As the rest of the combine functions do not take care of the cases where the types may be different as does the DAGCombiner however. 

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


More information about the llvm-commits mailing list