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

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue May 7 09:25:43 PDT 2019


Author: spatel
Date: Tue May  7 09:25:43 2019
New Revision: 360170

URL: http://llvm.org/viewvc/llvm-project?rev=360170&view=rev
Log:
[InstCombine] add tests for FP min/max with negated operands; NFC

Modified:
    llvm/trunk/test/Transforms/InstCombine/minmax-fp.ll

Modified: llvm/trunk/test/Transforms/InstCombine/minmax-fp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/minmax-fp.ll?rev=360170&r1=360169&r2=360170&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/minmax-fp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/minmax-fp.ll Tue May  7 09:25:43 2019
@@ -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
+}




More information about the llvm-commits mailing list