summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-05-07 18:58:07 +0000
committerSanjay Patel <spatel@rotateright.com>2019-05-07 18:58:07 +0000
commit6a281a75450a23346bb24077c7e019183fe1d498 (patch)
treeadc01ea1e2969656c7e366366b64d639f02be27d /llvm/test/Transforms
parent102ec0977d17069812c505c4b1faae0266a34625 (diff)
downloadbcm5719-llvm-6a281a75450a23346bb24077c7e019183fe1d498.tar.gz
bcm5719-llvm-6a281a75450a23346bb24077c7e019183fe1d498.zip
[InstCombine] allow sinking fneg operands through an FP min/max
Fundamentally/generally, we should not have to rely on bailouts/crippling of folds. In this particular case, I think we always recognize the inverted predicate min/max pattern, so there should not be any loss of optimization. Codegen looks better because we are eliminating an fneg. llvm-svn: 360180
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/InstCombine/minmax-fp.ll28
1 files changed, 12 insertions, 16 deletions
diff --git a/llvm/test/Transforms/InstCombine/minmax-fp.ll b/llvm/test/Transforms/InstCombine/minmax-fp.ll
index 9cdbf4f2d80..e139137727c 100644
--- a/llvm/test/Transforms/InstCombine/minmax-fp.ll
+++ b/llvm/test/Transforms/InstCombine/minmax-fp.ll
@@ -257,10 +257,9 @@ define double @t17(i32 %x) {
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: [[COND:%.*]] = fcmp nnan olt float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[MAX_V:%.*]] = select i1 [[COND]], float [[X]], float [[Y]]
+; CHECK-NEXT: [[MAX:%.*]] = fneg float [[MAX_V]]
; CHECK-NEXT: ret float [[MAX]]
;
%n1 = fneg float %x
@@ -272,10 +271,9 @@ define float @fneg_fmax(float %x, float %y) {
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: [[COND_INV:%.*]] = fcmp nnan nsz ogt <2 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[MAX_V:%.*]] = select <2 x i1> [[COND_INV]], <2 x float> [[Y]], <2 x float> [[X]]
+; CHECK-NEXT: [[MAX:%.*]] = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, [[MAX_V]]
; CHECK-NEXT: ret <2 x float> [[MAX]]
;
%n1 = fsub <2 x float> <float -0.0, float -0.0>, %x
@@ -287,10 +285,9 @@ define <2 x float> @fsub_fmax(<2 x float> %x, <2 x float> %y) {
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: [[COND:%.*]] = fcmp nnan ogt <2 x double> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[MAX_V:%.*]] = select <2 x i1> [[COND]], <2 x double> [[X]], <2 x double> [[Y]]
+; CHECK-NEXT: [[MAX:%.*]] = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, [[MAX_V]]
; CHECK-NEXT: ret <2 x double> [[MAX]]
;
%n1 = fsub <2 x double> <double -0.0, double -0.0>, %x
@@ -302,10 +299,9 @@ define <2 x double> @fsub_fmin(<2 x double> %x, <2 x double> %y) {
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: [[COND_INV:%.*]] = fcmp nnan nsz olt double [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[MAX_V:%.*]] = select i1 [[COND_INV]], double [[Y]], double [[X]]
+; CHECK-NEXT: [[MAX:%.*]] = fneg double [[MAX_V]]
; CHECK-NEXT: ret double [[MAX]]
;
%n1 = fneg double %x
OpenPOWER on IntegriCloud