[InstCombine] add tests for FP min/max with negated operands; NFC

llvm-svn: 360170
This commit is contained in:
Sanjay Patel 2019-05-07 16:25:43 +00:00
parent 7ff0c0ddd3
commit 2a3d16feea
1 changed files with 59 additions and 0 deletions

View File

@ -255,3 +255,62 @@ define double @t17(i32 %x) {
ret double %sel
}
define float @fneg_fmax(float %x, float %y) {
; CHECK-LABEL: @fneg_fmax(
; CHECK-NEXT: [[N1:%.*]] = fneg float [[X:%.*]]
; CHECK-NEXT: [[N2:%.*]] = fneg float [[Y:%.*]]
; CHECK-NEXT: [[COND:%.*]] = fcmp nnan ogt float [[N1]], [[N2]]
; CHECK-NEXT: [[MAX:%.*]] = select i1 [[COND]], float [[N1]], float [[N2]]
; CHECK-NEXT: ret float [[MAX]]
;
%n1 = fneg float %x
%n2 = fneg float %y
%cond = fcmp nnan ogt float %n1, %n2
%max = select i1 %cond, float %n1, float %n2
ret float %max
}
define <2 x float> @fsub_fmax(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: @fsub_fmax(
; CHECK-NEXT: [[N1:%.*]] = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, [[X:%.*]]
; CHECK-NEXT: [[N2:%.*]] = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, [[Y:%.*]]
; CHECK-NEXT: [[COND_INV:%.*]] = fcmp nnan nsz olt <2 x float> [[N1]], [[N2]]
; CHECK-NEXT: [[MAX:%.*]] = select <2 x i1> [[COND_INV]], <2 x float> [[N2]], <2 x float> [[N1]]
; CHECK-NEXT: ret <2 x float> [[MAX]]
;
%n1 = fsub <2 x float> <float -0.0, float -0.0>, %x
%n2 = fsub <2 x float> <float -0.0, float -0.0>, %y
%cond = fcmp nsz nnan uge <2 x float> %n1, %n2
%max = select <2 x i1> %cond, <2 x float> %n1, <2 x float> %n2
ret <2 x float> %max
}
define <2 x double> @fsub_fmin(<2 x double> %x, <2 x double> %y) {
; CHECK-LABEL: @fsub_fmin(
; CHECK-NEXT: [[N1:%.*]] = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, [[X:%.*]]
; CHECK-NEXT: [[N2:%.*]] = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, [[Y:%.*]]
; CHECK-NEXT: [[COND:%.*]] = fcmp nnan olt <2 x double> [[N1]], [[N2]]
; CHECK-NEXT: [[MAX:%.*]] = select <2 x i1> [[COND]], <2 x double> [[N1]], <2 x double> [[N2]]
; CHECK-NEXT: ret <2 x double> [[MAX]]
;
%n1 = fsub <2 x double> <double -0.0, double -0.0>, %x
%n2 = fsub <2 x double> <double -0.0, double -0.0>, %y
%cond = fcmp nnan olt <2 x double> %n1, %n2
%max = select <2 x i1> %cond, <2 x double> %n1, <2 x double> %n2
ret <2 x double> %max
}
define double @fneg_fmin(double %x, double %y) {
; CHECK-LABEL: @fneg_fmin(
; CHECK-NEXT: [[N1:%.*]] = fneg double [[X:%.*]]
; CHECK-NEXT: [[N2:%.*]] = fneg double [[Y:%.*]]
; CHECK-NEXT: [[COND_INV:%.*]] = fcmp nnan nsz ogt double [[N1]], [[N2]]
; CHECK-NEXT: [[MAX:%.*]] = select i1 [[COND_INV]], double [[N2]], double [[N1]]
; CHECK-NEXT: ret double [[MAX]]
;
%n1 = fneg double %x
%n2 = fneg double %y
%cond = fcmp nsz nnan ule double %n1, %n2
%max = select i1 %cond, double %n1, double %n2
ret double %max
}