[InstCombine] Add preliminary tests for nested min/max combines. NFC

Summary: As requested in D53774.

Reviewers: spatel

Reviewed By: spatel

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D53875

llvm-svn: 345616
This commit is contained in:
Volkan Keles 2018-10-30 17:51:14 +00:00
parent bcde5afcac
commit 5a672b22e8
4 changed files with 242 additions and 2 deletions

View File

@ -145,6 +145,66 @@ define float @maximum_f32_val_nan(float %x) {
ret float %y ret float %y
} }
define float @maximum_f32_1_maximum_val_p0(float %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_val_p0(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.maximum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.maximum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.maximum.f32(float %x, float 0.0)
%z = call float @llvm.maximum.f32(float %y, float 1.0)
ret float %z
}
define float @maximum_f32_1_maximum_p0_val_fast(float %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_fast(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.maximum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call fast float @llvm.maximum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.maximum.f32(float 0.0, float %x)
%z = call fast float @llvm.maximum.f32(float %y, float 1.0)
ret float %z
}
define float @maximum_f32_1_maximum_p0_val_nnan_ninf(float %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_nnan_ninf(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.maximum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call nnan ninf float @llvm.maximum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.maximum.f32(float 0.0, float %x)
%z = call nnan ninf float @llvm.maximum.f32(float %y, float 1.0)
ret float %z
}
define float @maximum_f32_p0_maximum_val_n0(float %x) {
; CHECK-LABEL: @maximum_f32_p0_maximum_val_n0(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.maximum.f32(float %x, float -0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.maximum.f32(float [[Y]], float 0.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.maximum.f32(float %x, float -0.0)
%z = call float @llvm.maximum.f32(float %y, float 0.0)
ret float %z
}
define float @maximum_f32_1_maximum_p0_val(float %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.maximum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.maximum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.maximum.f32(float 0.0, float %x)
%z = call float @llvm.maximum.f32(float %y, float 1.0)
ret float %z
}
define <2 x float> @maximum_f32_1_maximum_val_p0_val_v2f32(<2 x float> %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_val_p0_val_v2f32(
; CHECK-NEXT: [[Y:%.*]] = call <2 x float> @llvm.maximum.v2f32(<2 x float> %x, <2 x float> zeroinitializer)
; CHECK-NEXT: [[RES:%.*]] = call <2 x float> @llvm.maximum.v2f32(<2 x float> [[Y]], <2 x float> <float 1.000000e+00, float 1.000000e+00>)
; CHECK-NEXT: ret <2 x float> [[RES]]
%y = call <2 x float> @llvm.maximum.v2f32(<2 x float> %x, <2 x float> zeroinitializer)
%z = call <2 x float> @llvm.maximum.v2f32(<2 x float> %y, <2 x float><float 1.0, float 1.0>)
ret <2 x float> %z
}
define float @maximum4(float %x, float %y, float %z, float %w) { define float @maximum4(float %x, float %y, float %z, float %w) {
; CHECK-LABEL: @maximum4( ; CHECK-LABEL: @maximum4(
; CHECK-NEXT: [[A:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float [[Y:%.*]]) ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float [[Y:%.*]])

View File

@ -145,6 +145,66 @@ define float @maxnum_f32_val_nan(float %x) {
ret float %y ret float %y
} }
define float @maxnum_f32_1_maxnum_val_p0(float %x) {
; CHECK-LABEL: @maxnum_f32_1_maxnum_val_p0(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.maxnum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.maxnum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.maxnum.f32(float %x, float 0.0)
%z = call float @llvm.maxnum.f32(float %y, float 1.0)
ret float %z
}
define float @maxnum_f32_1_maxnum_p0_val_fast(float %x) {
; CHECK-LABEL: @maxnum_f32_1_maxnum_p0_val_fast(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.maxnum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call fast float @llvm.maxnum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.maxnum.f32(float 0.0, float %x)
%z = call fast float @llvm.maxnum.f32(float %y, float 1.0)
ret float %z
}
define float @maxnum_f32_1_maxnum_p0_val_nnan_ninf(float %x) {
; CHECK-LABEL: @maxnum_f32_1_maxnum_p0_val_nnan_ninf(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.maxnum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call nnan ninf float @llvm.maxnum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.maxnum.f32(float 0.0, float %x)
%z = call nnan ninf float @llvm.maxnum.f32(float %y, float 1.0)
ret float %z
}
define float @maxnum_f32_p0_maxnum_val_n0(float %x) {
; CHECK-LABEL: @maxnum_f32_p0_maxnum_val_n0(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.maxnum.f32(float %x, float -0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.maxnum.f32(float [[Y]], float 0.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.maxnum.f32(float %x, float -0.0)
%z = call float @llvm.maxnum.f32(float %y, float 0.0)
ret float %z
}
define float @maxnum_f32_1_maxnum_p0_val(float %x) {
; CHECK-LABEL: @maxnum_f32_1_maxnum_p0_val(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.maxnum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.maxnum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.maxnum.f32(float 0.0, float %x)
%z = call float @llvm.maxnum.f32(float %y, float 1.0)
ret float %z
}
define <2 x float> @maxnum_f32_1_maxnum_val_p0_val_v2f32(<2 x float> %x) {
; CHECK-LABEL: @maxnum_f32_1_maxnum_val_p0_val_v2f32(
; CHECK-NEXT: [[Y:%.*]] = call <2 x float> @llvm.maxnum.v2f32(<2 x float> %x, <2 x float> zeroinitializer)
; CHECK-NEXT: [[RES:%.*]] = call <2 x float> @llvm.maxnum.v2f32(<2 x float> [[Y]], <2 x float> <float 1.000000e+00, float 1.000000e+00>)
; CHECK-NEXT: ret <2 x float> [[RES]]
%y = call <2 x float> @llvm.maxnum.v2f32(<2 x float> %x, <2 x float> zeroinitializer)
%z = call <2 x float> @llvm.maxnum.v2f32(<2 x float> %y, <2 x float><float 1.0, float 1.0>)
ret <2 x float> %z
}
define float @maxnum4(float %x, float %y, float %z, float %w) { define float @maxnum4(float %x, float %y, float %z, float %w) {
; CHECK-LABEL: @maxnum4( ; CHECK-LABEL: @maxnum4(
; CHECK-NEXT: [[A:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float [[Y:%.*]]) ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float [[Y:%.*]])

View File

@ -2,7 +2,7 @@
; RUN: opt -S -instcombine < %s | FileCheck %s ; RUN: opt -S -instcombine < %s | FileCheck %s
declare float @llvm.minimum.f32(float, float) declare float @llvm.minimum.f32(float, float)
declare float @llvm.minimum.v2f32(<2 x float>, <2 x float>) declare <2 x float> @llvm.minimum.v2f32(<2 x float>, <2 x float>)
declare <4 x float> @llvm.minimum.v4f32(<4 x float>, <4 x float>) declare <4 x float> @llvm.minimum.v4f32(<4 x float>, <4 x float>)
declare double @llvm.minimum.f64(double, double) declare double @llvm.minimum.f64(double, double)
@ -147,6 +147,66 @@ define float @minimum_f32_val_nan(float %x) {
ret float %y ret float %y
} }
define float @minimum_f32_1_minimum_val_p0(float %x) {
; CHECK-LABEL: @minimum_f32_1_minimum_val_p0(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.minimum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.minimum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.minimum.f32(float %x, float 0.0)
%z = call float @llvm.minimum.f32(float %y, float 1.0)
ret float %z
}
define float @minimum_f32_1_minimum_p0_val_fast(float %x) {
; CHECK-LABEL: @minimum_f32_1_minimum_p0_val_fast(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.minimum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call fast float @llvm.minimum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.minimum.f32(float 0.0, float %x)
%z = call fast float @llvm.minimum.f32(float %y, float 1.0)
ret float %z
}
define float @minimum_f32_1_minimum_p0_val_nnan_ninf(float %x) {
; CHECK-LABEL: @minimum_f32_1_minimum_p0_val_nnan_ninf(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.minimum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call nnan ninf float @llvm.minimum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.minimum.f32(float 0.0, float %x)
%z = call nnan ninf float @llvm.minimum.f32(float %y, float 1.0)
ret float %z
}
define float @minimum_f32_p0_minimum_val_n0(float %x) {
; CHECK-LABEL: @minimum_f32_p0_minimum_val_n0(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.minimum.f32(float %x, float -0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.minimum.f32(float [[Y]], float 0.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.minimum.f32(float %x, float -0.0)
%z = call float @llvm.minimum.f32(float %y, float 0.0)
ret float %z
}
define float @minimum_f32_1_minimum_p0_val(float %x) {
; CHECK-LABEL: @minimum_f32_1_minimum_p0_val(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.minimum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.minimum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.minimum.f32(float 0.0, float %x)
%z = call float @llvm.minimum.f32(float %y, float 1.0)
ret float %z
}
define <2 x float> @minimum_f32_1_minimum_val_p0_val_v2f32(<2 x float> %x) {
; CHECK-LABEL: @minimum_f32_1_minimum_val_p0_val_v2f32(
; CHECK-NEXT: [[Y:%.*]] = call <2 x float> @llvm.minimum.v2f32(<2 x float> %x, <2 x float> zeroinitializer)
; CHECK-NEXT: [[RES:%.*]] = call <2 x float> @llvm.minimum.v2f32(<2 x float> [[Y]], <2 x float> <float 1.000000e+00, float 1.000000e+00>)
; CHECK-NEXT: ret <2 x float> [[RES]]
%y = call <2 x float> @llvm.minimum.v2f32(<2 x float> %x, <2 x float> zeroinitializer)
%z = call <2 x float> @llvm.minimum.v2f32(<2 x float> %y, <2 x float><float 1.0, float 1.0>)
ret <2 x float> %z
}
define float @minimum4(float %x, float %y, float %z, float %w) { define float @minimum4(float %x, float %y, float %z, float %w) {
; CHECK-LABEL: @minimum4( ; CHECK-LABEL: @minimum4(
; CHECK-NEXT: [[A:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float [[Y:%.*]]) ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float [[Y:%.*]])

View File

@ -2,7 +2,7 @@
; RUN: opt -S -instcombine < %s | FileCheck %s ; RUN: opt -S -instcombine < %s | FileCheck %s
declare float @llvm.minnum.f32(float, float) declare float @llvm.minnum.f32(float, float)
declare float @llvm.minnum.v2f32(<2 x float>, <2 x float>) declare <2 x float> @llvm.minnum.v2f32(<2 x float>, <2 x float>)
declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>) declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>)
declare double @llvm.minnum.f64(double, double) declare double @llvm.minnum.f64(double, double)
@ -147,6 +147,66 @@ define float @minnum_f32_val_nan(float %x) {
ret float %y ret float %y
} }
define float @minnum_f32_1_minnum_val_p0(float %x) {
; CHECK-LABEL: @minnum_f32_1_minnum_val_p0(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.minnum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.minnum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.minnum.f32(float %x, float 0.0)
%z = call float @llvm.minnum.f32(float %y, float 1.0)
ret float %z
}
define float @minnum_f32_1_minnum_p0_val_fast(float %x) {
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_fast(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.minnum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call fast float @llvm.minnum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.minnum.f32(float 0.0, float %x)
%z = call fast float @llvm.minnum.f32(float %y, float 1.0)
ret float %z
}
define float @minnum_f32_1_minnum_p0_val_nnan_ninf(float %x) {
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_nnan_ninf(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.minnum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call nnan ninf float @llvm.minnum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.minnum.f32(float 0.0, float %x)
%z = call nnan ninf float @llvm.minnum.f32(float %y, float 1.0)
ret float %z
}
define float @minnum_f32_p0_minnum_val_n0(float %x) {
; CHECK-LABEL: @minnum_f32_p0_minnum_val_n0(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.minnum.f32(float %x, float -0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.minnum.f32(float [[Y]], float 0.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.minnum.f32(float %x, float -0.0)
%z = call float @llvm.minnum.f32(float %y, float 0.0)
ret float %z
}
define float @minnum_f32_1_minnum_p0_val(float %x) {
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val(
; CHECK-NEXT: [[Y:%.*]] = call float @llvm.minnum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.minnum.f32(float [[Y]], float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.minnum.f32(float 0.0, float %x)
%z = call float @llvm.minnum.f32(float %y, float 1.0)
ret float %z
}
define <2 x float> @minnum_f32_1_minnum_val_p0_val_v2f32(<2 x float> %x) {
; CHECK-LABEL: @minnum_f32_1_minnum_val_p0_val_v2f32(
; CHECK-NEXT: [[Y:%.*]] = call <2 x float> @llvm.minnum.v2f32(<2 x float> %x, <2 x float> zeroinitializer)
; CHECK-NEXT: [[RES:%.*]] = call <2 x float> @llvm.minnum.v2f32(<2 x float> [[Y]], <2 x float> <float 1.000000e+00, float 1.000000e+00>)
; CHECK-NEXT: ret <2 x float> [[RES]]
%y = call <2 x float> @llvm.minnum.v2f32(<2 x float> %x, <2 x float> zeroinitializer)
%z = call <2 x float> @llvm.minnum.v2f32(<2 x float> %y, <2 x float><float 1.0, float 1.0>)
ret <2 x float> %z
}
define float @minnum4(float %x, float %y, float %z, float %w) { define float @minnum4(float %x, float %y, float %z, float %w) {
; CHECK-LABEL: @minnum4( ; CHECK-LABEL: @minnum4(
; CHECK-NEXT: [[A:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]]) ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])