[llvm] r213377 - NVPTX: support fpext/fptrunc to and from f16.
Tim Northover
tnorthover at apple.com
Fri Jul 18 06:01:43 PDT 2014
Author: tnorthover
Date: Fri Jul 18 08:01:43 2014
New Revision: 213377
URL: http://llvm.org/viewvc/llvm-project?rev=213377&view=rev
Log:
NVPTX: support fpext/fptrunc to and from f16.
Modified:
llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
llvm/trunk/test/CodeGen/NVPTX/half.ll
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp?rev=213377&r1=213376&r2=213377&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp Fri Jul 18 08:01:43 2014
@@ -203,8 +203,11 @@ NVPTXTargetLowering::NVPTXTargetLowering
setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::Other, Custom);
// Turn FP extload into load/fextend
+ setLoadExtAction(ISD::EXTLOAD, MVT::f16, Expand);
setLoadExtAction(ISD::EXTLOAD, MVT::f32, Expand);
// Turn FP truncstore into trunc + store.
+ setTruncStoreAction(MVT::f32, MVT::f16, Expand);
+ setTruncStoreAction(MVT::f64, MVT::f16, Expand);
setTruncStoreAction(MVT::f64, MVT::f32, Expand);
// PTX does not support load / store predicate registers
Modified: llvm/trunk/test/CodeGen/NVPTX/half.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/NVPTX/half.ll?rev=213377&r1=213376&r2=213377&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/NVPTX/half.ll (original)
+++ llvm/trunk/test/CodeGen/NVPTX/half.ll Fri Jul 18 08:01:43 2014
@@ -28,3 +28,43 @@ define void @test_bitcast_to_half(half a
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: cvt.f32.f16
+
+ %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: cvt.f64.f16
+
+ %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: cvt.rn.f16.f32
+
+ %val32 = load float addrspace(1)* %in
+ %val16 = fptrunc float %val32 to half
+ store half %val16, half addrspace(1)* %out
+ ret void
+}
+
+define void @test_trunc64(double addrspace(1)* %in, half addrspace(1)* %out) {
+; CHECK-LABEL: @test_trunc64
+; CHECK: cvt.rn.f16.f64
+
+ %val32 = load double addrspace(1)* %in
+ %val16 = fptrunc double %val32 to half
+ store half %val16, half addrspace(1)* %out
+ ret void
+}
More information about the llvm-commits
mailing list