[PATCH] D139668: [InstCombine] try to fold a pair of insertelements into one insertelement

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 12:44:35 PST 2022


spatel created this revision.
spatel added reviewers: dmgreen, RKSimon, lebedev.ri, nikic.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: All.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This replaces patches that tried to convert related patterns to shuffles (D138872 <https://reviews.llvm.org/D138872>, D138873 <https://reviews.llvm.org/D138873>, D138874 <https://reviews.llvm.org/D138874> - reverted/abandoned) but caused codegen problems and were questionable as a canonicalization because an insertelement is a simpler op than a shuffle.

This detects a larger pattern -- insert-of-insert -- and replaces with another insert, so this hopefully does not cause any problems.

As noted by TODO items in the code and tests, this could go a lot further. But this is enough to reduce the motivating test from issue #17113 <https://github.com/llvm/llvm-project/issues/17113>.

Example proofs:
https://alive2.llvm.org/ce/z/NnUv3a

I drafted a version of this for AggressiveInstCombine, but it seems that would uncover yet another phase ordering gap. If we do generalize this to handle the full range of potential patterns, that may be worth looking at again.


https://reviews.llvm.org/D139668

Files:
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/test/Transforms/InstCombine/insertelt-trunc.ll
  llvm/test/Transforms/PhaseOrdering/X86/vec-load-combine.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139668.481407.patch
Type: text/x-patch
Size: 23484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221208/01a01459/attachment.bin>


More information about the llvm-commits mailing list