[PATCH] D118317: [InstCombine] Fold and-reduce idiom

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 26 22:52:10 PST 2022


mkazantsev created this revision.
mkazantsev added reviewers: spatel, nikic, greened, RKSimon, dmakogon.
Herald added a subscriber: hiraditya.
mkazantsev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch introduces folding of add-reduce idiom and generates code
that is easier to read and which is lest costly in terms of icmp operations.
The folding is

  icmp eq (bitcast(icmp ne (lhs, rhs)), 0)

into

  icmp eq(bitcast(lhs), bitcast(rhs))


https://reviews.llvm.org/D118317

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/test/Transforms/InstCombine/icmp-vec.ll
  llvm/test/Transforms/InstCombine/reduction-and-sext-zext-i1.ll
  llvm/test/Transforms/InstCombine/reduction-or-sext-zext-i1.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118317.403505.patch
Type: text/x-patch
Size: 5356 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220127/44b6c35e/attachment.bin>


More information about the llvm-commits mailing list