mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-18 18:42:46 +02:00
[ValueTracking] Support min/max intrinsics in computeConstantRange()
The implementation is the same as for the SPF_* case.
This commit is contained in:
parent
cfe9647681
commit
2a8504a89f
@ -6414,6 +6414,33 @@ static void setLimitsForIntrinsic(const IntrinsicInst &II, APInt &Lower,
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Intrinsic::umin:
|
||||
case Intrinsic::umax:
|
||||
case Intrinsic::smin:
|
||||
case Intrinsic::smax:
|
||||
if (!match(II.getOperand(0), m_APInt(C)) &&
|
||||
!match(II.getOperand(1), m_APInt(C)))
|
||||
break;
|
||||
|
||||
switch (II.getIntrinsicID()) {
|
||||
case Intrinsic::umin:
|
||||
Upper = *C + 1;
|
||||
break;
|
||||
case Intrinsic::umax:
|
||||
Lower = *C;
|
||||
break;
|
||||
case Intrinsic::smin:
|
||||
Lower = APInt::getSignedMinValue(Width);
|
||||
Upper = *C + 1;
|
||||
break;
|
||||
case Intrinsic::smax:
|
||||
Lower = *C;
|
||||
Upper = APInt::getSignedMaxValue(Width) + 1;
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Must be min/max intrinsic");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1856,9 +1856,7 @@ define i8 @umin_umin_umin(i8 %x, i8 %y) {
|
||||
|
||||
define i1 @umin_ult_diff_const(i8 %x) {
|
||||
; CHECK-LABEL: @umin_ult_diff_const(
|
||||
; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 10)
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[M]], 20
|
||||
; CHECK-NEXT: ret i1 [[C]]
|
||||
; CHECK-NEXT: ret i1 true
|
||||
;
|
||||
%m = call i8 @llvm.umin.i8(i8 %x, i8 10)
|
||||
%c = icmp ult i8 %m, 20
|
||||
@ -1867,9 +1865,7 @@ define i1 @umin_ult_diff_const(i8 %x) {
|
||||
|
||||
define i1 @umax_ugt_diff_const(i8 %x) {
|
||||
; CHECK-LABEL: @umax_ugt_diff_const(
|
||||
; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 10)
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[M]], 5
|
||||
; CHECK-NEXT: ret i1 [[C]]
|
||||
; CHECK-NEXT: ret i1 true
|
||||
;
|
||||
%m = call i8 @llvm.umax.i8(i8 %x, i8 10)
|
||||
%c = icmp ugt i8 %m, 5
|
||||
@ -1878,9 +1874,7 @@ define i1 @umax_ugt_diff_const(i8 %x) {
|
||||
|
||||
define i1 @smin_slt_diff_const(i8 %x) {
|
||||
; CHECK-LABEL: @smin_slt_diff_const(
|
||||
; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 10)
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[M]], 20
|
||||
; CHECK-NEXT: ret i1 [[C]]
|
||||
; CHECK-NEXT: ret i1 true
|
||||
;
|
||||
%m = call i8 @llvm.smin.i8(i8 %x, i8 10)
|
||||
%c = icmp slt i8 %m, 20
|
||||
@ -1889,9 +1883,7 @@ define i1 @smin_slt_diff_const(i8 %x) {
|
||||
|
||||
define i1 @smax_sgt_diff_const(i8 %x) {
|
||||
; CHECK-LABEL: @smax_sgt_diff_const(
|
||||
; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 10)
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[M]], 5
|
||||
; CHECK-NEXT: ret i1 [[C]]
|
||||
; CHECK-NEXT: ret i1 true
|
||||
;
|
||||
%m = call i8 @llvm.smax.i8(i8 %x, i8 10)
|
||||
%c = icmp sgt i8 %m, 5
|
||||
|
Loading…
Reference in New Issue
Block a user