[PATCH] D94862: [InstCombine] Replace one-use select operand based on condition
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 16 04:23:13 PST 2021
nikic created this revision.
nikic added reviewers: aqjune, spatel, lebedev.ri.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
InstCombine already performs a fold where `X == Y ? f(X) : Z` is transformed to `X == Y ? f(Y) : Z` if `f(Y)` simplifies. However, if `f(X)` only has one use, then we can always directly replace the use inside the instruction. To actually be profitable, limit it to the case where `Y` is a non-expr constant.
This could be further extended to replace uses further up a one-use instruction chain, but for now this only looks one level up.
Among other things, this also subsumes D94860 <https://reviews.llvm.org/D94860>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D94862
Files:
lib/Transforms/InstCombine/InstCombineSelect.cpp
test/Transforms/InstCombine/select-binop-cmp.ll
test/Transforms/InstCombine/select-safe-transforms.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94862.317165.patch
Type: text/x-patch
Size: 10793 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210116/4ad9956b/attachment.bin>
More information about the llvm-commits
mailing list