From a4be3eff5c957fb280dbcc693c5cd966e9e3c158 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 13 Sep 2019 04:04:55 +0000 Subject: [PATCH] AMDGPU/GlobalISel: Legalize s32->s16 G_SITOFP/G_UITOFP llvm-svn: 371811 --- llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp | 2 +- llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sitofp.mir | 17 +++++++++++++++++ llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-uitofp.mir | 17 +++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp index 565a12b..0c7ab7a 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp @@ -416,7 +416,7 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_, .scalarize(0); getActionDefinitionsBuilder({G_SITOFP, G_UITOFP}) - .legalFor({{S32, S32}, {S64, S32}}) + .legalFor({{S32, S32}, {S64, S32}, {S16, S32}}) .lowerFor({{S32, S64}}) .customFor({{S64, S64}}) .scalarize(0); diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sitofp.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sitofp.mir index 33a0733..8c4d9d0 100644 --- a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sitofp.mir +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sitofp.mir @@ -141,3 +141,20 @@ body: | %1:_(s64) = G_SITOFP %0 $vgpr0_vgpr1 = COPY %1 ... + +--- +name: test_sitofp_s32_to_s16 +body: | + bb.0: + liveins: $vgpr0 + + ; CHECK-LABEL: name: test_sitofp_s32_to_s16 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 + ; CHECK: [[SITOFP:%[0-9]+]]:_(s16) = G_SITOFP [[COPY]](s32) + ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[SITOFP]](s16) + ; CHECK: $vgpr0 = COPY [[ANYEXT]](s32) + %0:_(s32) = COPY $vgpr0 + %1:_(s16) = G_SITOFP %0 + %2:_(s32) = G_ANYEXT %1 + $vgpr0 = COPY %2 +... diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-uitofp.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-uitofp.mir index 3573630..2ac82876 100644 --- a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-uitofp.mir +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-uitofp.mir @@ -110,3 +110,20 @@ body: | %1:_(s64) = G_UITOFP %0 $vgpr0_vgpr1 = COPY %1 ... + +--- +name: test_uitofp_s32_to_s16 +body: | + bb.0: + liveins: $vgpr0 + + ; CHECK-LABEL: name: test_uitofp_s32_to_s16 + ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 + ; CHECK: [[UITOFP:%[0-9]+]]:_(s16) = G_UITOFP [[COPY]](s32) + ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[UITOFP]](s16) + ; CHECK: $vgpr0 = COPY [[ANYEXT]](s32) + %0:_(s32) = COPY $vgpr0 + %1:_(s16) = G_UITOFP %0 + %2:_(s32) = G_ANYEXT %1 + $vgpr0 = COPY %2 +... -- 2.7.4