summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/max-of-nots.ll
diff options
context:
space:
mode:
authorAnna Thomas <anna@azul.com>2017-02-21 14:40:28 +0000
committerAnna Thomas <anna@azul.com>2017-02-21 14:40:28 +0000
commitec36f3b79a2e5c67624cae5aa2658d2caba8c990 (patch)
treeb598466c93521fbb8c8c0e19a49e1e46c956c5d3 /llvm/test/Transforms/InstCombine/max-of-nots.ll
parent812f3197945c6994ba393579636639a76f2b2e9b (diff)
downloadbcm5719-llvm-ec36f3b79a2e5c67624cae5aa2658d2caba8c990.tar.gz
bcm5719-llvm-ec36f3b79a2e5c67624cae5aa2658d2caba8c990.zip
[InstCombine] Do not exercise nested max/min pattern on abs
Summary: This is a fix for assertion failure in `getInverseMinMaxSelectPattern` when ABS is passed in as a select pattern. We should not be invoking the simplification rule for ABS(MIN(~ x,y))) or ABS(MAX(~x,y)) combinations. Added a test case which would cause an assertion failure without the patch. Reviewers: sanjoy, majnemer Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30051 llvm-svn: 295719
Diffstat (limited to 'llvm/test/Transforms/InstCombine/max-of-nots.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/max-of-nots.ll22
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/max-of-nots.ll b/llvm/test/Transforms/InstCombine/max-of-nots.ll
index 96fac522897..519f1c6a90b 100644
--- a/llvm/test/Transforms/InstCombine/max-of-nots.ll
+++ b/llvm/test/Transforms/InstCombine/max-of-nots.ll
@@ -90,6 +90,28 @@ define i32 @max_of_nots(i32 %x, i32 %y) {
ret i32 %smax96
}
+ ; negative test case (i.e. can not simplify) : ABS(MIN(NOT x,y))
+define i32 @abs_of_min_of_not(i32 %x, i32 %y) {
+; CHECK-LABEL: @abs_of_min_of_not(
+; CHECK-NEXT: xor
+; CHECK-NEXT: add
+; CHECK-NEXT: icmp sge
+; CHECK-NEXT: select
+; CHECK-NEXT: icmp sgt
+; CHECK-NEXT: sub
+; CHECK-NEXT: select
+; CHECK-NEXT: ret
+
+ %xord = xor i32 %x, -1
+ %yadd = add i32 %y, 2
+ %cond.i = icmp sge i32 %yadd, %xord
+ %min = select i1 %cond.i, i32 %xord, i32 %yadd
+ %cmp2 = icmp sgt i32 %min, -1
+ %sub = sub i32 0, %min
+ %abs = select i1 %cmp2, i32 %min, i32 %sub
+ ret i32 %abs
+}
+
define <2 x i32> @max_of_nots_vec(<2 x i32> %x, <2 x i32> %y) {
; CHECK-LABEL: @max_of_nots_vec(
; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <2 x i32> %y, zeroinitializer
OpenPOWER on IntegriCloud