CodeGen: extend f16 conversions to permit types > float.
This makes the two intrinsics @llvm.convert.from.f16 and
@llvm.convert.to.f16 accept types other than simple "float". This is
only strictly needed for the truncate operation, since otherwise
double rounding occurs and there's no way to represent the strict IEEE
conversion. However, for symmetry we allow larger types in the extend
too.
During legalization, we can expand an "fp16_to_double" operation into
two extends for convenience, but abort when the truncate isn't legal. A new
libcall is probably needed here.
Even after this commit, various target tweaks are needed to actually use the
extended intrinsics. I've put these into separate commits for clarity, so there
are no actual tests of f64 conversion here.
llvm-svn: 213248
diff --git a/llvm/test/CodeGen/X86/cvt16.ll b/llvm/test/CodeGen/X86/cvt16.ll
index 951b5c3..f3d8049 100644
--- a/llvm/test/CodeGen/X86/cvt16.ll
+++ b/llvm/test/CodeGen/X86/cvt16.ll
@@ -21,7 +21,7 @@
define void @test1(float %src, i16* %dest) {
- %1 = tail call i16 @llvm.convert.to.fp16(float %src)
+ %1 = tail call i16 @llvm.convert.to.fp16.f32(float %src)
store i16 %1, i16* %dest, align 2
ret void
}
@@ -34,7 +34,7 @@
define float @test2(i16* nocapture %src) {
%1 = load i16* %src, align 2
- %2 = tail call float @llvm.convert.from.fp16(i16 %1)
+ %2 = tail call float @llvm.convert.from.fp16.f32(i16 %1)
ret float %2
}
; CHECK-LABEL: test2:
@@ -45,8 +45,8 @@
define float @test3(float %src) nounwind uwtable readnone {
- %1 = tail call i16 @llvm.convert.to.fp16(float %src)
- %2 = tail call float @llvm.convert.from.fp16(i16 %1)
+ %1 = tail call i16 @llvm.convert.to.fp16.f32(float %src)
+ %2 = tail call float @llvm.convert.from.fp16.f32(i16 %1)
ret float %2
}
@@ -59,6 +59,6 @@
; F16C-NEXT: vcvtph2ps
; F16C: ret
-declare float @llvm.convert.from.fp16(i16) nounwind readnone
-declare i16 @llvm.convert.to.fp16(float) nounwind readnone
+declare float @llvm.convert.from.fp16.f32(i16) nounwind readnone
+declare i16 @llvm.convert.to.fp16.f32(float) nounwind readnone