From 1a8bcdb72ecf4bf94c0e3a346ff84fd380e54cf9 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Fri, 18 Jul 2014 13:01:31 +0000 Subject: [PATCH] AArch64: support f16 extend/trunc operations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213375 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AArch64/AArch64ISelLowering.cpp | 1 + test/CodeGen/AArch64/half.ll | 36 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/lib/Target/AArch64/AArch64ISelLowering.cpp b/lib/Target/AArch64/AArch64ISelLowering.cpp index bf3832ca1de..9e64ea8883a 100644 --- a/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -305,6 +305,7 @@ AArch64TargetLowering::AArch64TargetLowering(TargetMachine &TM) // AArch64 does not have floating-point extending loads, i1 sign-extending // load, floating-point truncating stores, or v2i32->v2i16 truncating store. + setLoadExtAction(ISD::EXTLOAD, MVT::f16, Expand); setLoadExtAction(ISD::EXTLOAD, MVT::f32, Expand); setLoadExtAction(ISD::EXTLOAD, MVT::f64, Expand); setLoadExtAction(ISD::EXTLOAD, MVT::f80, Expand); diff --git a/test/CodeGen/AArch64/half.ll b/test/CodeGen/AArch64/half.ll index 735fc36952d..1ad255b48b6 100644 --- a/test/CodeGen/AArch64/half.ll +++ b/test/CodeGen/AArch64/half.ll @@ -24,3 +24,39 @@ define void @test_bitcast_to_half(half* %addr, i16 %in) { store half %val_fp, half* %addr ret void } + +define float @test_extend32(half* %addr) { +; CHECK-LABEL: test_extend32: +; CHECK: fcvt {{s[0-9]+}}, {{h[0-9]+}} + + %val16 = load half* %addr + %val32 = fpext half %val16 to float + ret float %val32 +} + +define double @test_extend64(half* %addr) { +; CHECK-LABEL: test_extend64: +; CHECK: fcvt {{d[0-9]+}}, {{h[0-9]+}} + + %val16 = load half* %addr + %val32 = fpext half %val16 to double + ret double %val32 +} + +define void @test_trunc32(float %in, half* %addr) { +; CHECK-LABEL: test_trunc32: +; CHECK: fcvt {{h[0-9]+}}, {{s[0-9]+}} + + %val16 = fptrunc float %in to half + store half %val16, half* %addr + ret void +} + +define void @test_trunc64(double %in, half* %addr) { +; CHECK-LABEL: test_trunc64: +; CHECK: fcvt {{h[0-9]+}}, {{d[0-9]+}} + + %val16 = fptrunc double %in to half + store half %val16, half* %addr + ret void +}