[llvm] [InstCombine, AArch64] Avoid vector Ext in case by-element operation variant apply for all elements (PR #140733)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue May 20 07:15:35 PDT 2025


================
@@ -18602,6 +18602,33 @@ static SDValue performBuildShuffleExtendCombine(SDValue BV, SelectionDAG &DAG) {
     SeenZExtOrSExt = true;
   }
 
+  // Avoid the said use of vector SExt/ZExt in case all vector elements are
+  // consumed and each shuffle's mask uses same index, in order to permit use of
+  // indexed OP (e.g. MLA, MUL) variants
+  EVT ExtendType = Extend->getValueType(0);
+  if (ExtendType.isVector() && !ExtendType.isScalableVT()) {
+    const int NumElements = ExtendType.getVectorNumElements();
+    SmallBitVector UsedElements(NumElements, false);
+    for (auto UI = Extend.getNode()->use_begin(),
+              UE = Extend.getNode()->use_end();
+         UI != UE; ++UI) {
----------------
fhahn wrote:

Is there a `Extend.getNode()->users()` that returns an iterator range? Then it could be something like 

```suggestion
    for (SDNode *Users :  UI = Extend.getNode()->users()) {
```



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


More information about the llvm-commits mailing list