diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-03-24 14:45:41 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-03-24 14:45:41 +0000 |
commit | 6a176d527cc7c0caa5341281cdfc18087c6c6e6d (patch) | |
tree | 88593ed7342f6d005cd9d1568dffc01d1612353a | |
parent | f7d0f7e6db04d9dfb16ee5b38bec29f3da3259cb (diff) | |
download | bcm5719-llvm-6a176d527cc7c0caa5341281cdfc18087c6c6e6d.tar.gz bcm5719-llvm-6a176d527cc7c0caa5341281cdfc18087c6c6e6d.zip |
[InstCombine] add multi-use/vector tests for intrinsic shrinking; NFC
llvm-svn: 328422
-rw-r--r-- | llvm/test/Transforms/InstCombine/double-float-shrink-2.ll | 184 |
1 files changed, 155 insertions, 29 deletions
diff --git a/llvm/test/Transforms/InstCombine/double-float-shrink-2.ll b/llvm/test/Transforms/InstCombine/double-float-shrink-2.ll index d907963e1b7..1364b6eeeac 100644 --- a/llvm/test/Transforms/InstCombine/double-float-shrink-2.ll +++ b/llvm/test/Transforms/InstCombine/double-float-shrink-2.ll @@ -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(float %C) { ; 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_fast(float %C) { ; 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_nearbyint(float %C) { ; 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( |