[PATCH] D12340: [X86] Remove unnecessary 3DNow declarations from Intrin.h

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 25 14:52:31 PDT 2015


RKSimon created this revision.
RKSimon added reviewers: echristo, mkuper, silvas, craig.topper.
RKSimon added a subscriber: cfe-commits.
RKSimon set the repository for this revision to rL LLVM.

Follow up to D12272

This adds the missing 3dnow intrinsics _m_to_float / _m_from_float and removes their unnecesary declarations from Intrin.h. These are really just wrappers to existing MMX instructions (they are moved to/from the MMX register as i32 as 3dnow doesn't provide float specific instructions). 

Final part to resolve PR23648

Repository:
  rL LLVM

http://reviews.llvm.org/D12340

Files:
  lib/Headers/Intrin.h
  lib/Headers/mm3dnow.h
  test/CodeGen/3dnow-builtins.c

Index: test/CodeGen/3dnow-builtins.c
===================================================================
--- test/CodeGen/3dnow-builtins.c
+++ test/CodeGen/3dnow-builtins.c
@@ -5,6 +5,18 @@
 
 #include <x86intrin.h>
 
+__m64 test_m_from_float(float f) {
+  // CHECK-LABEL: define i64 @test_m_from_float
+  // CHECK: insertelement <2 x i32> 
+  return _m_from_float(f);
+}
+
+float test_m_to_float(__m64 m) {
+  // CHECK-LABEL: define float @test_m_to_float
+  // CHECK: extractelement <2 x i32>
+  return _m_to_float(m);
+}
+
 __m64 test_m_pavgusb(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pavgusb
   // CHECK: @llvm.x86.3dnow.pavgusb
Index: lib/Headers/mm3dnow.h
===================================================================
--- lib/Headers/mm3dnow.h
+++ lib/Headers/mm3dnow.h
@@ -37,6 +37,20 @@
   __builtin_ia32_femms();
 }
 
+static __inline__ float __DEFAULT_FN_ATTRS
+_m_to_float(__m64 __m) {
+  union { int __i; float __f; } __t;
+  __t.__i = __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);
+  return __t.__f;
+}
+
+static __inline__ __m64 __DEFAULT_FN_ATTRS
+_m_from_float(float __f) {
+  union { int __i; float __f; } __t;
+  __t.__f = __f;
+  return (__m64)__builtin_ia32_vec_init_v2si(__t.__i, 0);
+}
+
 static __inline__ __m64 __DEFAULT_FN_ATTRS
 _m_pavgusb(__m64 __m1, __m64 __m2) {
   return (__m64)__builtin_ia32_pavgusb((__v8qi)__m1, (__v8qi)__m2);
Index: lib/Headers/Intrin.h
===================================================================
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -46,12 +46,6 @@
 extern "C" {
 #endif
 
-#if defined(__MMX__)
-/* And the random ones that aren't in those files. */
-__m64 _m_from_float(float);
-float _m_to_float(__m64);
-#endif
-
 /* Other assorted instruction intrinsics. */
 void __addfsbyte(unsigned long, unsigned char);
 void __addfsdword(unsigned long, unsigned long);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12340.33130.patch
Type: text/x-patch
Size: 1863 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150825/e0ec0968/attachment.bin>


More information about the cfe-commits mailing list