summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-03-18 22:26:27 +0000
committerNikita Popov <nikita.ppv@gmail.com>2019-03-18 22:26:27 +0000
commit3e9770d2dc28901ba3b7756c0714d8762279cce8 (patch)
treefe4438fbdef95e5325922f68d606c70edf24c037
parent8b653d0308cf1d663dcc778d80a3009038220f6f (diff)
downloadbcm5719-llvm-3e9770d2dc28901ba3b7756c0714d8762279cce8.tar.gz
bcm5719-llvm-3e9770d2dc28901ba3b7756c0714d8762279cce8.zip
Revert "[ValueTracking][InstSimplify] Support min/max selects in computeConstantRange()"
This reverts commit 106f0cdefb02afc3064268dc7a71419b409ed2f3. This change impacts the AMDGPU smed3.ll and umed3.ll codegen tests. llvm-svn: 356424
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp23
-rw-r--r--llvm/test/Transforms/InstCombine/minmax-fold.ll31
-rw-r--r--llvm/test/Transforms/InstSimplify/cmp_of_min_max.ll20
3 files changed, 17 insertions, 57 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 2988043c2a2..00123788f2f 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -5680,28 +5680,7 @@ static void setLimitsForSelectPattern(const SelectInst &SI, APInt &Lower,
return;
}
- const APInt *C;
- if (!match(LHS, m_APInt(C)) && !match(RHS, m_APInt(C)))
- return;
-
- switch (R.Flavor) {
- case SPF_UMIN:
- Upper = *C + 1;
- break;
- case SPF_UMAX:
- Lower = *C;
- break;
- case SPF_SMIN:
- Lower = APInt::getSignedMinValue(BitWidth);
- Upper = *C + 1;
- break;
- case SPF_SMAX:
- Lower = *C;
- Upper = APInt::getSignedMaxValue(BitWidth) + 1;
- break;
- default:
- break;
- }
+ // TODO Handle min/max flavors.
}
ConstantRange llvm::computeConstantRange(const Value *V, bool UseInstrInfo) {
diff --git a/llvm/test/Transforms/InstCombine/minmax-fold.ll b/llvm/test/Transforms/InstCombine/minmax-fold.ll
index 7b66eb4a416..d312155c523 100644
--- a/llvm/test/Transforms/InstCombine/minmax-fold.ll
+++ b/llvm/test/Transforms/InstCombine/minmax-fold.ll
@@ -533,37 +533,6 @@ define i32 @clamp_check_for_no_infinite_loop2(i32 %i) {
ret i32 %res
}
-; Check that there is no infinite loop because of reverse cmp transformation:
-; (icmp slt smax(PositiveA, B) 2) -> (icmp eq B 1)
-define i32 @clamp_check_for_no_infinite_loop3(i32 %i) {
-; CHECK-LABEL: @clamp_check_for_no_infinite_loop3(
-; CHECK-NEXT: [[I2:%.*]] = icmp sgt i32 [[I:%.*]], 1
-; CHECK-NEXT: [[I3:%.*]] = select i1 [[I2]], i32 [[I]], i32 1
-; CHECK-NEXT: br i1 true, label [[TRUELABEL:%.*]], label [[FALSELABEL:%.*]]
-; CHECK: truelabel:
-; CHECK-NEXT: [[I5:%.*]] = icmp slt i32 [[I3]], 2
-; CHECK-NEXT: [[I6:%.*]] = select i1 [[I5]], i32 [[I3]], i32 2
-; CHECK-NEXT: [[I7:%.*]] = shl nuw nsw i32 [[I6]], 2
-; CHECK-NEXT: ret i32 [[I7]]
-; CHECK: falselabel:
-; CHECK-NEXT: ret i32 0
-;
-
- %i2 = icmp sgt i32 %i, 1
- %i3 = select i1 %i2, i32 %i, i32 1
- %i4 = icmp sgt i32 %i3, 0
- br i1 %i4, label %truelabel, label %falselabel
-
-truelabel: ; %i<=1, %i3>0
- %i5 = icmp slt i32 %i3, 2
- %i6 = select i1 %i5, i32 %i3, i32 2
- %i7 = shl nuw nsw i32 %i6, 2
- ret i32 %i7
-
-falselabel:
- ret i32 0
-}
-
; The next 3 min tests should canonicalize to the same form...and not infinite loop.
define double @PR31751_umin1(i32 %x) {
diff --git a/llvm/test/Transforms/InstSimplify/cmp_of_min_max.ll b/llvm/test/Transforms/InstSimplify/cmp_of_min_max.ll
index 34c4a15aed1..4726609c3f5 100644
--- a/llvm/test/Transforms/InstSimplify/cmp_of_min_max.ll
+++ b/llvm/test/Transforms/InstSimplify/cmp_of_min_max.ll
@@ -3,7 +3,10 @@
define i1 @test_umax1(i32 %n) {
; CHECK-LABEL: @test_umax1(
-; CHECK-NEXT: ret i1 true
+; CHECK-NEXT: [[C1:%.*]] = icmp ugt i32 [[N:%.*]], 10
+; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 10
+; CHECK-NEXT: [[C2:%.*]] = icmp ugt i32 [[S]], 9
+; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp ugt i32 %n, 10
%s = select i1 %c1, i32 %n, i32 10
@@ -37,7 +40,10 @@ define i1 @test_umax3(i32 %n) {
define i1 @test_umin1(i32 %n) {
; CHECK-LABEL: @test_umin1(
-; CHECK-NEXT: ret i1 true
+; CHECK-NEXT: [[C1:%.*]] = icmp ult i32 [[N:%.*]], 10
+; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 10
+; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[S]], 11
+; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp ult i32 %n, 10
%s = select i1 %c1, i32 %n, i32 10
@@ -71,7 +77,10 @@ define i1 @test_umin3(i32 %n) {
define i1 @test_smax1(i32 %n) {
; CHECK-LABEL: @test_smax1(
-; CHECK-NEXT: ret i1 true
+; CHECK-NEXT: [[C1:%.*]] = icmp sgt i32 [[N:%.*]], -10
+; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 -10
+; CHECK-NEXT: [[C2:%.*]] = icmp sgt i32 [[S]], -11
+; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp sgt i32 %n, -10
%s = select i1 %c1, i32 %n, i32 -10
@@ -105,7 +114,10 @@ define i1 @test_smax3(i32 %n) {
define i1 @test_smin1(i32 %n) {
; CHECK-LABEL: @test_smin1(
-; CHECK-NEXT: ret i1 true
+; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[N:%.*]], 10
+; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 10
+; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[S]], 11
+; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp slt i32 %n, 10
%s = select i1 %c1, i32 %n, i32 10
OpenPOWER on IntegriCloud