From 00fdbbbf60bc2e4162530add780db3817fb48547 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Fri, 18 Jul 2014 13:01:37 +0000 Subject: [PATCH] R600: support fpext/fptrunc operations to and from f16. llvm-svn: 213376 --- llvm/lib/Target/R600/AMDGPUISelLowering.cpp | 4 +++ llvm/test/CodeGen/R600/half.ll | 31 +++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/llvm/lib/Target/R600/AMDGPUISelLowering.cpp b/llvm/lib/Target/R600/AMDGPUISelLowering.cpp index 42d2a13a398a..c8120ae5c35c 100644 --- a/llvm/lib/Target/R600/AMDGPUISelLowering.cpp +++ b/llvm/lib/Target/R600/AMDGPUISelLowering.cpp @@ -244,6 +244,10 @@ AMDGPUTargetLowering::AMDGPUTargetLowering(TargetMachine &TM) : setOperationAction(ISD::FP16_TO_FP, MVT::f64, Expand); + setLoadExtAction(ISD::EXTLOAD, MVT::f16, Expand); + setTruncStoreAction(MVT::f32, MVT::f16, Expand); + setTruncStoreAction(MVT::f64, MVT::f16, Expand); + const MVT ScalarIntVTs[] = { MVT::i32, MVT::i64 }; for (MVT VT : ScalarIntVTs) { setOperationAction(ISD::SREM, VT, Expand); diff --git a/llvm/test/CodeGen/R600/half.ll b/llvm/test/CodeGen/R600/half.ll index 58d3a1bdf47b..42aa4faa99f4 100644 --- a/llvm/test/CodeGen/R600/half.ll +++ b/llvm/test/CodeGen/R600/half.ll @@ -28,3 +28,34 @@ define void @test_bitcast_to_half(half addrspace(1)* %out, i16 addrspace(1)* %in store half %val_fp, half addrspace(1)* %out ret void } + +define void @test_extend32(half addrspace(1)* %in, float addrspace(1)* %out) { +; CHECK-LABEL: @test_extend32 +; CHECK: V_CVT_F32_F16_e32 + + %val16 = load half addrspace(1)* %in + %val32 = fpext half %val16 to float + store float %val32, float addrspace(1)* %out + ret void +} + +define void @test_extend64(half addrspace(1)* %in, double addrspace(1)* %out) { +; CHECK-LABEL: @test_extend64 +; CHECK: V_CVT_F32_F16_e32 +; CHECK: V_CVT_F64_F32_e32 + + %val16 = load half addrspace(1)* %in + %val64 = fpext half %val16 to double + store double %val64, double addrspace(1)* %out + ret void +} + +define void @test_trunc32(float addrspace(1)* %in, half addrspace(1)* %out) { +; CHECK-LABEL: @test_trunc32 +; CHECK: V_CVT_F16_F32_e32 + + %val32 = load float addrspace(1)* %in + %val16 = fptrunc float %val32 to half + store half %val16, half addrspace(1)* %out + ret void +} -- 2.34.1