[InstSimplify] add tests for minnum/maxnum; NFC

This isn't the best fix for PR37776, but it probably
hides the bug with the given code example:
https://bugs.llvm.org/show_bug.cgi?id=37776

We have another test to demonstrate the more general
bug.

llvm-svn: 337126
This commit is contained in:
Sanjay Patel 2018-07-15 14:46:48 +00:00
parent f279169d9e
commit ef71b704c2
1 changed files with 82 additions and 0 deletions

View File

@ -462,3 +462,85 @@ define float @fabs_select_positive_constants_vector_extract(i32 %c) {
%fabs = call float @llvm.fabs.f32(float %extract)
ret float %fabs
}
declare double @llvm.minnum.f64(double, double)
declare double @llvm.maxnum.f64(double, double)
declare <2 x double> @llvm.minnum.v2f64(<2 x double>, <2 x double>)
declare <2 x double> @llvm.maxnum.v2f64(<2 x double>, <2 x double>)
; From the LangRef for minnum/maxnum:
; "follows the IEEE-754 semantics for maxNum, which also match for libms fmax.
; If either operand is a NaN, returns the other non-NaN operand."
define double @maxnum_nan_op0(double %x) {
; CHECK-LABEL: @maxnum_nan_op0(
; CHECK-NEXT: [[R:%.*]] = call double @llvm.maxnum.f64(double 0x7FF8000000000000, double [[X:%.*]])
; CHECK-NEXT: ret double [[R]]
;
%r = call double @llvm.maxnum.f64(double 0x7ff8000000000000, double %x)
ret double %r
}
define double @maxnum_nan_op1(double %x) {
; CHECK-LABEL: @maxnum_nan_op1(
; CHECK-NEXT: [[R:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double 0x7FF800000000DEAD)
; CHECK-NEXT: ret double [[R]]
;
%r = call double @llvm.maxnum.f64(double %x, double 0x7ff800000000dead)
ret double %r
}
define double @minnum_nan_op0(double %x) {
; CHECK-LABEL: @minnum_nan_op0(
; CHECK-NEXT: [[R:%.*]] = call double @llvm.minnum.f64(double 0x7FF8000DEAD00000, double [[X:%.*]])
; CHECK-NEXT: ret double [[R]]
;
%r = call double @llvm.minnum.f64(double 0x7ff8000dead00000, double %x)
ret double %r
}
define double @minnum_nan_op1(double %x) {
; CHECK-LABEL: @minnum_nan_op1(
; CHECK-NEXT: [[R:%.*]] = call double @llvm.minnum.f64(double [[X:%.*]], double 0x7FF800DEAD00DEAD)
; CHECK-NEXT: ret double [[R]]
;
%r = call double @llvm.minnum.f64(double %x, double 0x7ff800dead00dead)
ret double %r
}
define <2 x double> @maxnum_nan_op0_vec(<2 x double> %x) {
; CHECK-LABEL: @maxnum_nan_op0_vec(
; CHECK-NEXT: [[R:%.*]] = call <2 x double> @llvm.maxnum.v2f64(<2 x double> <double 0x7FF8000000000000, double undef>, <2 x double> [[X:%.*]])
; CHECK-NEXT: ret <2 x double> [[R]]
;
%r = call <2 x double> @llvm.maxnum.v2f64(<2 x double> <double 0x7ff8000000000000, double undef>, <2 x double> %x)
ret <2 x double> %r
}
define <2 x double> @maxnum_nan_op1_vec(<2 x double> %x) {
; CHECK-LABEL: @maxnum_nan_op1_vec(
; CHECK-NEXT: [[R:%.*]] = call <2 x double> @llvm.maxnum.v2f64(<2 x double> [[X:%.*]], <2 x double> <double 0x7FF800000000DEAD, double 0x7FF8FFFFFFFFFFFF>)
; CHECK-NEXT: ret <2 x double> [[R]]
;
%r = call <2 x double> @llvm.maxnum.v2f64(<2 x double> %x, <2 x double> <double 0x7ff800000000dead, double 0x7ff8ffffffffffff>)
ret <2 x double> %r
}
define <2 x double> @minnum_nan_op0_vec(<2 x double> %x) {
; CHECK-LABEL: @minnum_nan_op0_vec(
; CHECK-NEXT: [[R:%.*]] = call <2 x double> @llvm.minnum.v2f64(<2 x double> <double undef, double 0x7FF8000DEAD00000>, <2 x double> [[X:%.*]])
; CHECK-NEXT: ret <2 x double> [[R]]
;
%r = call <2 x double> @llvm.minnum.v2f64(<2 x double> <double undef, double 0x7ff8000dead00000>, <2 x double> %x)
ret <2 x double> %r
}
define <2 x double> @minnum_nan_op1_vec(<2 x double> %x) {
; CHECK-LABEL: @minnum_nan_op1_vec(
; CHECK-NEXT: [[R:%.*]] = call <2 x double> @llvm.minnum.v2f64(<2 x double> [[X:%.*]], <2 x double> <double 0x7FF800DEAD00DEAD, double 0x7FF800DEAD00DEAD>)
; CHECK-NEXT: ret <2 x double> [[R]]
;
%r = call <2 x double> @llvm.minnum.v2f64(<2 x double> %x, <2 x double> <double 0x7ff800dead00dead, double 0x7ff800dead00dead>)
ret <2 x double> %r
}