[PATCH] D26525: [InstCombine] canonicalize min/max constant to select's false value

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 10 14:24:13 PST 2016


spatel created this revision.
spatel added reviewers: arsenm, hfinkel, jmolloy, efriedma, majnemer.
spatel added a subscriber: llvm-commits.
Herald added subscribers: wdng, mcrosier.

This is a first step towards canonicalization and improved folding/codegen for integer min/max as discussed here:
http://lists.llvm.org/pipermail/llvm-dev/2016-November/106868.html

Here, we're just matching the simplest min/max patterns and adjusting the icmp predicate while swapping the select operands.

I've included FIXME tests in test/Transforms/InstCombine/select_meta.ll so it's easier to see how this might be extended (corresponds to the TODO comment in the code). That's also why I'm using matchSelectPattern() rather than a simpler check; once the backend is patched, we can just remove some of the restrictions to allow the obfuscated min/max patterns in the FIXME tests to be matched.


https://reviews.llvm.org/D26525

Files:
  lib/Transforms/InstCombine/InstCombineSelect.cpp
  test/Transforms/InstCombine/adjust-for-minmax.ll
  test/Transforms/InstCombine/div-shift.ll
  test/Transforms/InstCombine/minmax-fold.ll
  test/Transforms/InstCombine/pr27236.ll
  test/Transforms/InstCombine/select_meta.ll
  test/Transforms/InstCombine/sext.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26525.77554.patch
Type: text/x-patch
Size: 32430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161110/64c406e4/attachment.bin>


More information about the llvm-commits mailing list