From 92b259c3ad38497948520281ff7ac1cbccc2e8ec Mon Sep 17 00:00:00 2001
From: Thomas Winwood <twwinwood@gmail.com>
Date: Sat, 9 Dec 2017 18:40:36 +0000
Subject: [PATCH 1/2] Add __floatdisf and __floatundisf intrinsics

---
 README.md         |  4 ++--
 src/float/conv.rs | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 5606ef4c8..cee6679e1 100644
--- a/README.md
+++ b/README.md
@@ -150,11 +150,11 @@ features = ["c"]
 - [x] fixunssfdi.c
 - [x] fixunssfsi.c
 - [x] floatdidf.c
-- [ ] floatdisf.c
+- [x] floatdisf.c
 - [x] floatsidf.c
 - [x] floatsisf.c
 - [x] floatundidf.c
-- [ ] floatundisf.c
+- [x] floatundisf.c
 - [x] floatunsidf.c
 - [x] floatunsisf.c
 - [ ] i386/ashldi3.S
diff --git a/src/float/conv.rs b/src/float/conv.rs
index 33644ce56..53844c17b 100644
--- a/src/float/conv.rs
+++ b/src/float/conv.rs
@@ -80,6 +80,18 @@ intrinsics! {
         int_to_float!(i, i32, f64)
     }
 
+    #[use_c_shim_if(all(target_arch = "x86", not(target_env = "msvc")))]
+    #[arm_aeabi_alias = __aeabi_l2f]
+    pub extern "C" fn __floatdisf(i: i64) -> f32 {
+        // On x86_64 LLVM will use native instructions for this conversion, we
+        // can just do it directly
+        if cfg!(target_arch = "x86_64") {
+            i as f32
+        } else {
+            int_to_float!(i, i64, f32)
+        }
+    }
+
     #[use_c_shim_if(all(target_arch = "x86", not(target_env = "msvc")))]
     #[arm_aeabi_alias = __aeabi_l2d]
     pub extern "C" fn __floatdidf(i: i64) -> f64 {
@@ -112,6 +124,14 @@ intrinsics! {
         int_to_float!(i, u32, f64)
     }
 
+    #[use_c_shim_if(all(not(target_env = "msvc"),
+                        any(target_arch = "x86",
+                            all(not(windows), target_arch = "x86_64"))))]
+    #[arm_aeabi_alias = __aeabi_ul2f]
+    pub extern "C" fn __floatundisf(i: u64) -> f32 {
+        int_to_float!(i, u64, f32)
+    }
+
     #[use_c_shim_if(all(not(target_env = "msvc"),
                         any(target_arch = "x86",
                             all(not(windows), target_arch = "x86_64"))))]

From e3dda361626d11eaad86f3e60d48c028ae94b4f9 Mon Sep 17 00:00:00 2001
From: Thomas Winwood <twwinwood@gmail.com>
Date: Thu, 5 Apr 2018 15:03:44 +0100
Subject: [PATCH 2/2] Remove reference to C impl of float[un]disf

---
 build.rs | 2 --
 1 file changed, 2 deletions(-)

diff --git a/build.rs b/build.rs
index 9c23c20c9..ab1cc4b27 100644
--- a/build.rs
+++ b/build.rs
@@ -4991,8 +4991,6 @@ mod c {
                 "divxc3.c",
                 "extendsfdf2.c",
                 "extendhfsf2.c",
-                "floatdisf.c",
-                "floatundisf.c",
                 "int_util.c",
                 "muldc3.c",
                 "mulsc3.c",