diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-11-21 22:04:14 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-11-21 22:04:14 +0000 |
commit | 3b0bafee6320277cf9daafa93bf9a612ea882882 (patch) | |
tree | 638040fc139ca5e8b0d807f3c0ba2179f1a7bdc4 /llvm/test/Transforms/InstCombine/div-shift.ll | |
parent | 8efbe6acaeaa8ce0fed7d710d3ccb48823a672f8 (diff) | |
download | bcm5719-llvm-3b0bafee6320277cf9daafa93bf9a612ea882882.tar.gz bcm5719-llvm-3b0bafee6320277cf9daafa93bf9a612ea882882.zip |
[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
llvm-svn: 287585
Diffstat (limited to 'llvm/test/Transforms/InstCombine/div-shift.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/div-shift.ll | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/test/Transforms/InstCombine/div-shift.ll b/llvm/test/Transforms/InstCombine/div-shift.ll index 053210650d1..517313ed8e4 100644 --- a/llvm/test/Transforms/InstCombine/div-shift.ll +++ b/llvm/test/Transforms/InstCombine/div-shift.ll @@ -45,8 +45,8 @@ define i64 @t3(i64 %x, i32 %y) { define i32 @t4(i32 %x, i32 %y) { ; CHECK-LABEL: @t4( -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 %y, 5 -; CHECK-NEXT: [[DOTV:%.*]] = select i1 [[TMP1]], i32 5, i32 %y +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 %y, 5 +; CHECK-NEXT: [[DOTV:%.*]] = select i1 [[TMP1]], i32 %y, i32 5 ; CHECK-NEXT: [[TMP2:%.*]] = lshr i32 %x, [[DOTV]] ; CHECK-NEXT: ret i32 [[TMP2]] ; |