diff --git a/llvm/test/Transforms/InstCombine/minmax-fp.ll b/llvm/test/Transforms/InstCombine/minmax-fp.ll index 11418156a485..9cdbf4f2d80c 100644 --- a/llvm/test/Transforms/InstCombine/minmax-fp.ll +++ b/llvm/test/Transforms/InstCombine/minmax-fp.ll @@ -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> , [[X:%.*]] +; CHECK-NEXT: [[N2:%.*]] = fsub <2 x float> , [[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> , %x + %n2 = fsub <2 x float> , %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> , [[X:%.*]] +; CHECK-NEXT: [[N2:%.*]] = fsub <2 x double> , [[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> , %x + %n2 = fsub <2 x double> , %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 +}