]> granicus.if.org Git - llvm/commit
[InstCombine] canonicalize min/max constant to select's false value
authorSanjay Patel <spatel@rotateright.com>
Mon, 21 Nov 2016 22:04:14 +0000 (22:04 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 21 Nov 2016 22:04:14 +0000 (22:04 +0000)
commitfea0530bd591e6a30336acbbfeef7b8cda3934b6
tree6302fbb946cf9d64f7500c6b4a2f290e5650df0a
parent150a3cafddbd248184e32ea9718147f080eda9e3
[InstCombine] canonicalize min/max constant to select's false value

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.

Differential Revision: https://reviews.llvm.org/D26525

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287585 91177308-0d34-0410-b5e6-96231b3b80d8
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