From cfd9e7f594dd944427631be19bd6ef5dbe8ee161 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sun, 20 Jan 2019 19:10:26 +0000 Subject: [PATCH] AMDGPU/GlobalISel: Legalize f32->f16 fptrunc llvm-svn: 351695 --- .../lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp | 2 +- .../AMDGPU/GlobalISel/legalize-fptrunc.mir | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp index f02c93dd7c46..61d344a31700 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp @@ -139,7 +139,7 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST, .legalFor({S32, S64}); getActionDefinitionsBuilder(G_FPTRUNC) - .legalFor({{S32, S64}}); + .legalFor({{S32, S64}, {S16, S32}}); getActionDefinitionsBuilder(G_FPEXT) .legalFor({{S64, S32}, {S32, S16}}) diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-fptrunc.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-fptrunc.mir index 40eae268917c..f2ed866424e4 100644 --- a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-fptrunc.mir +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-fptrunc.mir @@ -2,12 +2,12 @@ # RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=fiji -run-pass=legalizer -global-isel %s -o - | FileCheck %s --- -name: test_fptrunc_f64_to_f32 +name: test_fptrunc_s64_to_s32 body: | bb.0: liveins: $vgpr0_vgpr1 - ; CHECK-LABEL: name: test_fptrunc_f64_to_f32 + ; CHECK-LABEL: name: test_fptrunc_s64_to_s32 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1 ; CHECK: [[FPTRUNC:%[0-9]+]]:_(s32) = G_FPTRUNC [[COPY]](s64) ; CHECK: $vgpr0 = COPY [[FPTRUNC]](s32) @@ -15,3 +15,20 @@ body: | %1:_(s32) = G_FPTRUNC %0 $vgpr0 = COPY %1 ... + +--- +name: test_fptrunc_s32_to_s16 +body: | + bb.0: + liveins: $vgpr0 + + ; CHECK-LABEL: name: test_fptrunc_s32_to_s16 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 + ; CHECK: [[FPTRUNC:%[0-9]+]]:_(s16) = G_FPTRUNC [[COPY]](s32) + ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[FPTRUNC]](s16) + ; CHECK: $vgpr0 = COPY [[ANYEXT]](s32) + %0:_(s32) = COPY $vgpr0 + %1:_(s16) = G_FPTRUNC %0 + %2:_(s32) = G_ANYEXT %1 + $vgpr0 = COPY %2 +...