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

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 5 08:54:46 PDT 2022


spatel created this revision.
spatel added reviewers: dmgreen, RKSimon, xbolva00.
Herald added subscribers: pengfei, hiraditya, mcrosier.
Herald added a project: All.
spatel requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

insertelt DestVec, (fneg (extractelt SrcVec, Index)), Index --> shuffle DestVec, (fneg SrcVec), Mask

This is a specialized form of what could be a more general fold for a binop. It's also possible that fneg is overlooked by SLP in this kind of insert/extract pattern since it's a unary op.

This shows up in the motivating example from #issue 58139 <https://github.com/llvm/llvm-project/issues/58139>, but it won't solve it (that probably requires some x86-specific backend changes). There are also some small enhancements (see TODO comments) that can be done as follow-up patches.


https://reviews.llvm.org/D135278

Files:
  llvm/lib/Transforms/Vectorize/VectorCombine.cpp
  llvm/test/Transforms/VectorCombine/X86/extract-fneg-insert.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135278.465420.patch
Type: text/x-patch
Size: 8475 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221005/ff495ac1/attachment.bin>


More information about the llvm-commits mailing list