[llvm] r328422 - [InstCombine] add multi-use/vector tests for intrinsic shrinking; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 24 07:45:41 PDT 2018
Author: spatel
Date: Sat Mar 24 07:45:41 2018
New Revision: 328422
URL: http://llvm.org/viewvc/llvm-project?rev=328422&view=rev
Log:
[InstCombine] add multi-use/vector tests for intrinsic shrinking; NFC
Modified:
llvm/trunk/test/Transforms/InstCombine/double-float-shrink-2.ll
Modified: llvm/trunk/test/Transforms/InstCombine/double-float-shrink-2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/double-float-shrink-2.ll?rev=328422&r1=328421&r2=328422&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/double-float-shrink-2.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/double-float-shrink-2.ll Sat Mar 24 07:45:41 2018
@@ -13,15 +13,26 @@ declare double @nearbyint(double)
declare double @trunc(double)
declare double @fabs(double)
+declare double @llvm.ceil.f64(double)
+declare <2 x double> @llvm.ceil.v2f64(<2 x double>)
+
+declare double @llvm.fabs.f64(double)
+declare <2 x double> @llvm.fabs.v2f64(<2 x double>)
+
declare double @llvm.floor.f64(double)
declare <2 x double> @llvm.floor.v2f64(<2 x double>)
-declare double @llvm.ceil.f64(double)
+
+declare double @llvm.nearbyint.f64(double)
+declare <2 x double> @llvm.nearbyint.v2f64(<2 x double>)
+
+declare float @llvm.rint.f32(float)
+declare <2 x float> @llvm.rint.v2f32(<2 x float>)
+
declare double @llvm.round.f64(double)
declare <2 x double> @llvm.round.v2f64(<2 x double>)
-declare double @llvm.nearbyint.f64(double)
+
declare double @llvm.trunc.f64(double)
declare <2 x double> @llvm.trunc.v2f64(<2 x double>)
-declare double @llvm.fabs.f64(double)
define float @test_shrink_libcall_floor(float %C) {
; ALL-LABEL: @test_shrink_libcall_floor(
@@ -127,7 +138,6 @@ define float @test_shrink_libcall_fabs(f
; ALL-NEXT: ret float [[F]]
;
%D = fpext float %C to double
- ; --> fabsf
%E = call double @fabs(double %D)
%F = fptrunc double %E to float
ret float %F
@@ -140,44 +150,40 @@ define float @test_shrink_libcall_fabs_f
; ALL-NEXT: ret float [[F]]
;
%D = fpext float %C to double
- ; --> fabsf
%E = call fast double @fabs(double %D)
%F = fptrunc double %E to float
ret float %F
}
-define float @test_shrink_intrin_floor(float %C) {
-; ALL-LABEL: @test_shrink_intrin_floor(
-; ALL-NEXT: [[TMP1:%.*]] = call float @llvm.floor.f32(float [[C:%.*]])
+define float @test_shrink_intrin_ceil(float %C) {
+; ALL-LABEL: @test_shrink_intrin_ceil(
+; ALL-NEXT: [[TMP1:%.*]] = call float @llvm.ceil.f32(float [[C:%.*]])
; ALL-NEXT: ret float [[TMP1]]
;
%D = fpext float %C to double
- ; --> floorf
- %E = call double @llvm.floor.f64(double %D)
+ %E = call double @llvm.ceil.f64(double %D)
%F = fptrunc double %E to float
ret float %F
}
-define float @test_shrink_intrin_ceil(float %C) {
-; ALL-LABEL: @test_shrink_intrin_ceil(
-; ALL-NEXT: [[TMP1:%.*]] = call float @llvm.ceil.f32(float [[C:%.*]])
+define float @test_shrink_intrin_fabs(float %C) {
+; ALL-LABEL: @test_shrink_intrin_fabs(
+; ALL-NEXT: [[TMP1:%.*]] = call float @llvm.fabs.f32(float [[C:%.*]])
; ALL-NEXT: ret float [[TMP1]]
;
%D = fpext float %C to double
- ; --> ceilf
- %E = call double @llvm.ceil.f64(double %D)
+ %E = call double @llvm.fabs.f64(double %D)
%F = fptrunc double %E to float
ret float %F
}
-define float @test_shrink_intrin_round(float %C) {
-; ALL-LABEL: @test_shrink_intrin_round(
-; ALL-NEXT: [[TMP1:%.*]] = call float @llvm.round.f32(float [[C:%.*]])
+define float @test_shrink_intrin_floor(float %C) {
+; ALL-LABEL: @test_shrink_intrin_floor(
+; ALL-NEXT: [[TMP1:%.*]] = call float @llvm.floor.f32(float [[C:%.*]])
; ALL-NEXT: ret float [[TMP1]]
;
%D = fpext float %C to double
- ; --> roundf
- %E = call double @llvm.round.f64(double %D)
+ %E = call double @llvm.floor.f64(double %D)
%F = fptrunc double %E to float
ret float %F
}
@@ -188,34 +194,154 @@ define float @test_shrink_intrin_nearbyi
; ALL-NEXT: ret float [[TMP1]]
;
%D = fpext float %C to double
- ; --> nearbyintf
%E = call double @llvm.nearbyint.f64(double %D)
%F = fptrunc double %E to float
ret float %F
}
-define float @test_shrink_intrin_trunc(float %C) {
-; ALL-LABEL: @test_shrink_intrin_trunc(
-; ALL-NEXT: [[TMP1:%.*]] = call float @llvm.trunc.f32(float [[C:%.*]])
+define half @test_shrink_intrin_rint(half %C) {
+; ALL-LABEL: @test_shrink_intrin_rint(
+; ALL-NEXT: [[TMP1:%.*]] = call half @llvm.rint.f16(half [[C:%.*]])
+; ALL-NEXT: ret half [[TMP1]]
+;
+ %D = fpext half %C to float
+ %E = call float @llvm.rint.f32(float %D)
+ %F = fptrunc float %E to half
+ ret half %F
+}
+
+define float @test_shrink_intrin_round(float %C) {
+; ALL-LABEL: @test_shrink_intrin_round(
+; ALL-NEXT: [[TMP1:%.*]] = call float @llvm.round.f32(float [[C:%.*]])
; ALL-NEXT: ret float [[TMP1]]
;
%D = fpext float %C to double
- %E = call double @llvm.trunc.f64(double %D)
+ %E = call double @llvm.round.f64(double %D)
%F = fptrunc double %E to float
ret float %F
}
-define float @test_shrink_intrin_fabs(float %C) {
-; ALL-LABEL: @test_shrink_intrin_fabs(
-; ALL-NEXT: [[TMP1:%.*]] = call float @llvm.fabs.f32(float [[C:%.*]])
+define float @test_shrink_intrin_trunc(float %C) {
+; ALL-LABEL: @test_shrink_intrin_trunc(
+; ALL-NEXT: [[TMP1:%.*]] = call float @llvm.trunc.f32(float [[C:%.*]])
; ALL-NEXT: ret float [[TMP1]]
;
%D = fpext float %C to double
- %E = call double @llvm.fabs.f64(double %D)
+ %E = call double @llvm.trunc.f64(double %D)
%F = fptrunc double %E to float
ret float %F
}
+declare void @use_v2f64(<2 x double>)
+declare void @use_v2f32(<2 x float>)
+
+define <2 x float> @test_shrink_intrin_ceil_multi_use(<2 x float> %C) {
+; ALL-LABEL: @test_shrink_intrin_ceil_multi_use(
+; ALL-NEXT: [[D:%.*]] = fpext <2 x float> [[C:%.*]] to <2 x double>
+; ALL-NEXT: [[E:%.*]] = call <2 x double> @llvm.ceil.v2f64(<2 x double> [[D]])
+; ALL-NEXT: [[F:%.*]] = fptrunc <2 x double> [[E]] to <2 x float>
+; ALL-NEXT: call void @use_v2f64(<2 x double> [[D]])
+; ALL-NEXT: ret <2 x float> [[F]]
+;
+ %D = fpext <2 x float> %C to <2 x double>
+ %E = call <2 x double> @llvm.ceil.v2f64(<2 x double> %D)
+ %F = fptrunc <2 x double> %E to <2 x float>
+ call void @use_v2f64(<2 x double> %D)
+ ret <2 x float> %F
+}
+
+define <2 x float> @test_shrink_intrin_fabs_multi_use(<2 x float> %C) {
+; ALL-LABEL: @test_shrink_intrin_fabs_multi_use(
+; ALL-NEXT: [[TMP1:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[C:%.*]])
+; ALL-NEXT: [[E:%.*]] = fpext <2 x float> [[TMP1]] to <2 x double>
+; ALL-NEXT: call void @use_v2f64(<2 x double> [[E]])
+; ALL-NEXT: ret <2 x float> [[TMP1]]
+;
+ %D = fpext <2 x float> %C to <2 x double>
+ %E = call <2 x double> @llvm.fabs.v2f64(<2 x double> %D)
+ %F = fptrunc <2 x double> %E to <2 x float>
+ call void @use_v2f64(<2 x double> %E)
+ ret <2 x float> %F
+}
+
+define <2 x float> @test_shrink_intrin_floor_multi_use(<2 x float> %C) {
+; ALL-LABEL: @test_shrink_intrin_floor_multi_use(
+; ALL-NEXT: [[D:%.*]] = fpext <2 x float> [[C:%.*]] to <2 x double>
+; ALL-NEXT: [[E:%.*]] = call <2 x double> @llvm.floor.v2f64(<2 x double> [[D]])
+; ALL-NEXT: [[F:%.*]] = fptrunc <2 x double> [[E]] to <2 x float>
+; ALL-NEXT: call void @use_v2f64(<2 x double> [[D]])
+; ALL-NEXT: call void @use_v2f64(<2 x double> [[E]])
+; ALL-NEXT: ret <2 x float> [[F]]
+;
+ %D = fpext <2 x float> %C to <2 x double>
+ %E = call <2 x double> @llvm.floor.v2f64(<2 x double> %D)
+ %F = fptrunc <2 x double> %E to <2 x float>
+ call void @use_v2f64(<2 x double> %D)
+ call void @use_v2f64(<2 x double> %E)
+ ret <2 x float> %F
+}
+
+define <2 x float> @test_shrink_intrin_nearbyint_multi_use(<2 x float> %C) {
+; ALL-LABEL: @test_shrink_intrin_nearbyint_multi_use(
+; ALL-NEXT: [[D:%.*]] = fpext <2 x float> [[C:%.*]] to <2 x double>
+; ALL-NEXT: [[E:%.*]] = call <2 x double> @llvm.nearbyint.v2f64(<2 x double> [[D]])
+; ALL-NEXT: [[F:%.*]] = fptrunc <2 x double> [[E]] to <2 x float>
+; ALL-NEXT: call void @use_v2f64(<2 x double> [[D]])
+; ALL-NEXT: ret <2 x float> [[F]]
+;
+ %D = fpext <2 x float> %C to <2 x double>
+ %E = call <2 x double> @llvm.nearbyint.v2f64(<2 x double> %D)
+ %F = fptrunc <2 x double> %E to <2 x float>
+ call void @use_v2f64(<2 x double> %D)
+ ret <2 x float> %F
+}
+
+define <2 x half> @test_shrink_intrin_rint_multi_use(<2 x half> %C) {
+; ALL-LABEL: @test_shrink_intrin_rint_multi_use(
+; ALL-NEXT: [[TMP1:%.*]] = call <2 x half> @llvm.rint.v2f16(<2 x half> [[C:%.*]])
+; ALL-NEXT: [[E:%.*]] = fpext <2 x half> [[TMP1]] to <2 x float>
+; ALL-NEXT: call void @use_v2f32(<2 x float> [[E]])
+; ALL-NEXT: ret <2 x half> [[TMP1]]
+;
+ %D = fpext <2 x half> %C to <2 x float>
+ %E = call <2 x float> @llvm.rint.v2f32(<2 x float> %D)
+ %F = fptrunc <2 x float> %E to <2 x half>
+ call void @use_v2f32(<2 x float> %E)
+ ret <2 x half> %F
+}
+
+define <2 x float> @test_shrink_intrin_round_multi_use(<2 x float> %C) {
+; ALL-LABEL: @test_shrink_intrin_round_multi_use(
+; ALL-NEXT: [[D:%.*]] = fpext <2 x float> [[C:%.*]] to <2 x double>
+; ALL-NEXT: [[E:%.*]] = call <2 x double> @llvm.round.v2f64(<2 x double> [[D]])
+; ALL-NEXT: [[F:%.*]] = fptrunc <2 x double> [[E]] to <2 x float>
+; ALL-NEXT: call void @use_v2f64(<2 x double> [[D]])
+; ALL-NEXT: call void @use_v2f64(<2 x double> [[E]])
+; ALL-NEXT: ret <2 x float> [[F]]
+;
+ %D = fpext <2 x float> %C to <2 x double>
+ %E = call <2 x double> @llvm.round.v2f64(<2 x double> %D)
+ %F = fptrunc <2 x double> %E to <2 x float>
+ call void @use_v2f64(<2 x double> %D)
+ call void @use_v2f64(<2 x double> %E)
+ ret <2 x float> %F
+}
+
+define <2 x float> @test_shrink_intrin_trunc_multi_use(<2 x float> %C) {
+; ALL-LABEL: @test_shrink_intrin_trunc_multi_use(
+; ALL-NEXT: [[D:%.*]] = fpext <2 x float> [[C:%.*]] to <2 x double>
+; ALL-NEXT: [[E:%.*]] = call <2 x double> @llvm.trunc.v2f64(<2 x double> [[D]])
+; ALL-NEXT: [[F:%.*]] = fptrunc <2 x double> [[E]] to <2 x float>
+; ALL-NEXT: call void @use_v2f64(<2 x double> [[D]])
+; ALL-NEXT: ret <2 x float> [[F]]
+;
+ %D = fpext <2 x float> %C to <2 x double>
+ %E = call <2 x double> @llvm.trunc.v2f64(<2 x double> %D)
+ %F = fptrunc <2 x double> %E to <2 x float>
+ call void @use_v2f64(<2 x double> %D)
+ ret <2 x float> %F
+}
+
; Make sure fast math flags are preserved
define float @test_shrink_intrin_fabs_fast(float %C) {
; ALL-LABEL: @test_shrink_intrin_fabs_fast(
More information about the llvm-commits
mailing list