[PATCH] R600/SI: Add a pattern for f32 ftrunc

Matt Arsenault arsenm2 at gmail.com
Wed Jun 18 09:42:22 PDT 2014


On Jun 18, 2014, at 9:11 AM, Tom Stellard <thomas.stellard at amd.com> wrote:


> -; RUN: llc -march=r600 -mcpu=bonaire < %s | FileCheck -check-prefix=CI %s
> +; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG --check-prefix=FUNC %s
> +; RUN: llc -march=r600 -mcpu=SI < %s | FileCheck -check-prefix=SI --check-prefix=FUNC %s
> 
> -declare double @llvm.trunc.f64(double) nounwind readnone
> -declare <2 x double> @llvm.trunc.v2f64(<2 x double>) nounwind readnone
> -declare <3 x double> @llvm.trunc.v3f64(<3 x double>) nounwind readnone
> -declare <4 x double> @llvm.trunc.v4f64(<4 x double>) nounwind readnone
> -declare <8 x double> @llvm.trunc.v8f64(<8 x double>) nounwind readnone
> -declare <16 x double> @llvm.trunc.v16f64(<16 x double>) nounwind readnone
> +declare float @llvm.trunc.f32(float) nounwind readnone
> +declare <2 x float> @llvm.trunc.v2f32(<2 x float>) nounwind readnone
> +declare <3 x float> @llvm.trunc.v3f32(<3 x float>) nounwind readnone
> +declare <4 x float> @llvm.trunc.v4f32(<4 x float>) nounwind readnone
> +declare <8 x float> @llvm.trunc.v8f32(<8 x float>) nounwind readnone
> +declare <16 x float> @llvm.trunc.v16f32(<16 x float>) nounwind readnone
> 
> -; CI-LABEL: @ftrunc_f64:
> -; CI: V_TRUNC_F64_e32
> -define void @ftrunc_f64(double addrspace(1)* %out, double %x) {
> -  %y = call double @llvm.trunc.f64(double %x) nounwind readnone
> -  store double %y, double addrspace(1)* %out
> +; FUNC-LABEL: @ftrunc_f32:
> +; EG: TRUNC
> +; SI: V_TRUNC_F32_e32
> +define void @ftrunc_f32(float addrspace(1)* %out, float %x) {
> +  %y = call float @llvm.trunc.f32(float %x) nounwind readnone
> +  store float %y, float addrspace(1)* %out
>   ret void
> }
> 
> -; CI-LABEL: @ftrunc_v2f64:
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -define void @ftrunc_v2f64(<2 x double> addrspace(1)* %out, <2 x double> %x) {
> -  %y = call <2 x double> @llvm.trunc.v2f64(<2 x double> %x) nounwind readnone
> -  store <2 x double> %y, <2 x double> addrspace(1)* %out
> +; FUNC-LABEL: @ftrunc_v2f32:
> +; EG: TRUNC
> +; EG: TRUNC
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +define void @ftrunc_v2f32(<2 x float> addrspace(1)* %out, <2 x float> %x) {
> +  %y = call <2 x float> @llvm.trunc.v2f32(<2 x float> %x) nounwind readnone
> +  store <2 x float> %y, <2 x float> addrspace(1)* %out
>   ret void
> }
> 
> -; FIXME-CI-LABEL: @ftrunc_v3f64:
> -; FIXME-CI: V_TRUNC_F64_e32
> -; FIXME-CI: V_TRUNC_F64_e32
> -; FIXME-CI: V_TRUNC_F64_e32
> -; define void @ftrunc_v3f64(<3 x double> addrspace(1)* %out, <3 x double> %x) {
> -;   %y = call <3 x double> @llvm.trunc.v3f64(<3 x double> %x) nounwind readnone
> -;   store <3 x double> %y, <3 x double> addrspace(1)* %out
> +; FIXME-FUNC-LABEL: @ftrunc_v3f32:
> +; FIXME-EG: TRUNC
> +; FIXME-EG: TRUNC
> +; FIXME-EG: TRUNC
> +; FIXME-SI: V_TRUNC_F32_e32
> +; FIXME-SI: V_TRUNC_F32_e32
> +; FIXME-SI: V_TRUNC_F32_e32
> +; define void @ftrunc_v3f32(<3 x float> addrspace(1)* %out, <3 x float> %x) {
> +;   %y = call <3 x float> @llvm.trunc.v3f32(<3 x float> %x) nounwind readnone
> +;   store <3 x float> %y, <3 x float> addrspace(1)* %out
> ;   ret void
> ; }
> 
> -; CI-LABEL: @ftrunc_v4f64:
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -define void @ftrunc_v4f64(<4 x double> addrspace(1)* %out, <4 x double> %x) {
> -  %y = call <4 x double> @llvm.trunc.v4f64(<4 x double> %x) nounwind readnone
> -  store <4 x double> %y, <4 x double> addrspace(1)* %out
> +; FUNC-LABEL: @ftrunc_v4f32:
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +define void @ftrunc_v4f32(<4 x float> addrspace(1)* %out, <4 x float> %x) {
> +  %y = call <4 x float> @llvm.trunc.v4f32(<4 x float> %x) nounwind readnone
> +  store <4 x float> %y, <4 x float> addrspace(1)* %out
>   ret void
> }
> 
> -; CI-LABEL: @ftrunc_v8f64:
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -define void @ftrunc_v8f64(<8 x double> addrspace(1)* %out, <8 x double> %x) {
> -  %y = call <8 x double> @llvm.trunc.v8f64(<8 x double> %x) nounwind readnone
> -  store <8 x double> %y, <8 x double> addrspace(1)* %out
> +; FUNC-LABEL: @ftrunc_v8f32:
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +define void @ftrunc_v8f32(<8 x float> addrspace(1)* %out, <8 x float> %x) {
> +  %y = call <8 x float> @llvm.trunc.v8f32(<8 x float> %x) nounwind readnone
> +  store <8 x float> %y, <8 x float> addrspace(1)* %out
>   ret void
> }
> 
> -; CI-LABEL: @ftrunc_v16f64:
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -; CI: V_TRUNC_F64_e32
> -define void @ftrunc_v16f64(<16 x double> addrspace(1)* %out, <16 x double> %x) {
> -  %y = call <16 x double> @llvm.trunc.v16f64(<16 x double> %x) nounwind readnone
> -  store <16 x double> %y, <16 x double> addrspace(1)* %out
> +; FUNC-LABEL: @ftrunc_v16f32:
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; EG: TRUNC
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +; SI: V_TRUNC_F32_e32
> +define void @ftrunc_v16f32(<16 x float> addrspace(1)* %out, <16 x float> %x) {
> +  %y = call <16 x float> @llvm.trunc.v16f32(<16 x float> %x) nounwind readnone
> +  store <16 x float> %y, <16 x float> addrspace(1)* %out
>   ret void
> }
> diff --git a/test/CodeGen/R600/ftrunc64.ll b/test/CodeGen/R600/ftrunc64.ll
> new file mode 100644
> index 0000000..6b235ff
> --- /dev/null
> +++ b/test/CodeGen/R600/ftrunc64.ll
> @@ -0,0 +1,84 @@
> +; RUN: llc -march=r600 -mcpu=bonaire < %s | FileCheck -check-prefix=CI %s
> +
> +declare double @llvm.trunc.f64(double) nounwind readnone
> +declare <2 x double> @llvm.trunc.v2f64(<2 x double>) nounwind readnone
> +declare <3 x double> @llvm.trunc.v3f64(<3 x double>) nounwind readnone
> +declare <4 x double> @llvm.trunc.v4f64(<4 x double>) nounwind readnone
> +declare <8 x double> @llvm.trunc.v8f64(<8 x double>) nounwind readnone
> +declare <16 x double> @llvm.trunc.v16f64(<16 x double>) nounwind readnone
> +
> +; CI-LABEL: @ftrunc_f64:
> +; CI: V_TRUNC_F64_e32
> +define void @ftrunc_f64(double addrspace(1)* %out, double %x) {
> +  %y = call double @llvm.trunc.f64(double %x) nounwind readnone
> +  store double %y, double addrspace(1)* %out
> +  ret void
> +}
> +
> +; CI-LABEL: @ftrunc_v2f64:
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +define void @ftrunc_v2f64(<2 x double> addrspace(1)* %out, <2 x double> %x) {
> +  %y = call <2 x double> @llvm.trunc.v2f64(<2 x double> %x) nounwind readnone
> +  store <2 x double> %y, <2 x double> addrspace(1)* %out
> +  ret void
> +}
> +
> +; FIXME-CI-LABEL: @ftrunc_v3f64:
> +; FIXME-CI: V_TRUNC_F64_e32
> +; FIXME-CI: V_TRUNC_F64_e32
> +; FIXME-CI: V_TRUNC_F64_e32
> +; define void @ftrunc_v3f64(<3 x double> addrspace(1)* %out, <3 x double> %x) {
> +;   %y = call <3 x double> @llvm.trunc.v3f64(<3 x double> %x) nounwind readnone
> +;   store <3 x double> %y, <3 x double> addrspace(1)* %out
> +;   ret void
> +; }
> +
> +; CI-LABEL: @ftrunc_v4f64:
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +define void @ftrunc_v4f64(<4 x double> addrspace(1)* %out, <4 x double> %x) {
> +  %y = call <4 x double> @llvm.trunc.v4f64(<4 x double> %x) nounwind readnone
> +  store <4 x double> %y, <4 x double> addrspace(1)* %out
> +  ret void
> +}
> +
> +; CI-LABEL: @ftrunc_v8f64:
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +define void @ftrunc_v8f64(<8 x double> addrspace(1)* %out, <8 x double> %x) {
> +  %y = call <8 x double> @llvm.trunc.v8f64(<8 x double> %x) nounwind readnone
> +  store <8 x double> %y, <8 x double> addrspace(1)* %out
> +  ret void
> +}
> +
> +; CI-LABEL: @ftrunc_v16f64:
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +; CI: V_TRUNC_F64_e32
> +define void @ftrunc_v16f64(<16 x double> addrspace(1)* %out, <16 x double> %x) {
> +  %y = call <16 x double> @llvm.trunc.v16f64(<16 x double> %x) nounwind readnone
> +  store <16 x double> %y, <16 x double> addrspace(1)* %out
> +  ret void
> +}
> -- 
> 1.8.1.5
> 

You can just delete the f64 version of the tests for now. My patch implementing them for pre-SI redos these





More information about the llvm-commits mailing list