[PATCH] D135278: [VectorCombine] convert scalar fneg with insert/extract to vector fneg

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 10 05:16:47 PDT 2022


RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: llvm/lib/Transforms/Vectorize/VectorCombine.cpp:563
+  SmallVector<int> Mask;
+  for (unsigned i = 0, e = VecTy->getNumElements(); i != e; ++i) {
+    if (i == Index)
----------------
tschuett wrote:
> Tiniest nit: You could `Mask.reserve(VecTy->getNumElements());`
If you wanted to you could go even further (assuming we know that Index < VecTy->getNumElements())
```
SmallVector<int> Mask(VecTy->getNumElements());
std::iota(Mask.begin(), Mask.end(), 0);
Mask[Index] = Index + e;
```


================
Comment at: llvm/test/Transforms/VectorCombine/X86/extract-fneg-insert.ll:7
 
+; TODO: The insert is costed as free, so creating a shuffle appears to be a loss.
+
----------------
Are you going to look at this? If not please can you raise a bug.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135278/new/

https://reviews.llvm.org/D135278



More information about the llvm-commits mailing list