[llvm] [VectorCombine] Scalarize extracts of ZExt if profitable. (PR #142976)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 5 11:03:20 PDT 2025


================
@@ -1710,6 +1711,72 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
   return true;
 }
 
+bool VectorCombine::scalarizeExtExtract(Instruction &I) {
+  if (!match(&I, m_ZExt(m_Value())))
+    return false;
+
+  // Try to convert a vector zext feeding only extracts to a set of scalar (Src
+  // << ExtIdx *Size) & (Size -1), if profitable.
+  auto *Ext = cast<ZExtInst>(&I);
+  auto *SrcTy = cast<FixedVectorType>(Ext->getOperand(0)->getType());
+  auto *DstTy = cast<FixedVectorType>(Ext->getType());
----------------
fhahn wrote:

Ah yes, this can be called with scalable vectors, added a check.

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


More information about the llvm-commits mailing list