[PATCH] D34242: [InstCombine] canonicalize icmp predicate feeding select

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 15 09:32:45 PDT 2017


spatel created this revision.
Herald added a subscriber: mcrosier.

This canonicalization was suggested in https://reviews.llvm.org/D33172 as a way to make InstCombine behavior more uniform. We have this transform for icmp+br, so unless there's some reason that icmp+select should be treated differently, I think we should do the same thing here.

The benefit comes from increasing the chances of creating identical instructions. This is shown in the tests in logical-select.ll (PR32791). InstCombine doesn't fold those directly, but EarlyCSE can simplify the identical cmps, and then InstCombine can fold the selects together.

The possible regression for the tests in select.ll raises questions about poison/undef:
http://lists.llvm.org/pipermail/llvm-dev/2017-May/113261.html

...but I think that transform is just as likely to be triggered by this canonicalization as it is to be missed, so we're just pointing out a commutation deficiency in the pattern matching:
https://reviews.llvm.org/rL228409


https://reviews.llvm.org/D34242

Files:
  lib/Transforms/InstCombine/InstCombineSelect.cpp
  test/Transforms/InstCombine/ffs-1.ll
  test/Transforms/InstCombine/icmp.ll
  test/Transforms/InstCombine/logical-select.ll
  test/Transforms/InstCombine/max-of-nots.ll
  test/Transforms/InstCombine/select-with-bitwise-ops.ll
  test/Transforms/InstCombine/select.ll
  test/Transforms/LoopVectorize/if-conversion.ll
  test/Transforms/LoopVectorize/minmax_reduction.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34242.102675.patch
Type: text/x-patch
Size: 12190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170615/6e5611a2/attachment.bin>


More information about the llvm-commits mailing list