[llvm] [VectorCombine] Preserves the maximal legal FPMathFlags during foldShuffleToIdentity (PR #94295)

David Green via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 4 09:58:22 PDT 2024


================
@@ -1736,23 +1741,49 @@ static Value *generateNewInstTree(ArrayRef<InstLane> Item, FixedVectorType *Ty,
     Ops[Idx] = generateNewInstTree(generateInstLaneVectorFromOperand(Item, Idx),
                                    Ty, IdentityLeafs, SplatLeafs, Builder);
   }
+
+  SmallVector<Value *, 8> ValueList;
+  for (const auto &Lane : Item) {
+    if (Lane.second != FrontLane || !Lane.first)
+      continue;
+    ValueList.push_back(Lane.first);
----------------
davemgreen wrote:

Maybe use a SmallPtrSet to make sure each item is added once, and then convert that to a SmallVector? It might not be a problem to add them multiple times though, in which case it could just add them all. I don't think it should need to check `Lane.second != FrontLane`.
```
for (const auto &Lane : Item) {
  if (Lane.first)
    ValueList.push_back(Lane.first);
}
```

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


More information about the llvm-commits mailing list