This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR46041, define fma macros if -save-temps


This patch fixes the definition of the __FP_FAST_FMA, __FP_FAST_FMAF, and
__FP_FAST_FMAL macros to work if -save-temps is used.  Because it no longer
needs to look at the optab structures, I moved it to the c-cppbuiltin.c
function and made it static.  Once I do the two bootstraps and there are no
regressions, is it ok to apply?

[gcc]
2010-10-18  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/46041
	* tree.h (mode_has_fma): Delete, move to c-cppbuiltins.c.
	* builtins.c (mode_has_fma): Ditto.

[gcc/c-family]
2010-10-18  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/46041
	* c-cppbuiltin.c (mode_has_fma): Move function here from
	builtins.c.  Don't use the fma optab, instead just use the
	HAVE_fma* macros, so that __FP_FAST_FMA* will be defined when
	using -save-temps.

Index: gcc/tree.h
===================================================================
--- gcc/tree.h	(revision 165653)
+++ gcc/tree.h	(working copy)
@@ -5069,7 +5069,6 @@ extern bool merge_ranges (int *, tree *,
 extern void set_builtin_user_assembler_name (tree decl, const char *asmspec);
 extern bool is_simple_builtin (tree);
 extern bool is_inexpensive_builtin (tree);
-extern bool mode_has_fma (enum machine_mode mode);
 
 /* In convert.c */
 extern tree strip_float_extensions (tree);
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 165653)
+++ gcc/builtins.c	(working copy)
@@ -13909,11 +13909,3 @@ is_inexpensive_builtin (tree decl)
 
   return false;
 }
-
-/* Return true if MODE provides a fast multiply/add (FMA) builtin function.  */
-
-bool
-mode_has_fma (enum machine_mode mode)
-{
-  return optab_handler (fma_optab, mode) != CODE_FOR_nothing;
-}
Index: gcc/c-family/c-cppbuiltin.c
===================================================================
--- gcc/c-family/c-cppbuiltin.c	(revision 165653)
+++ gcc/c-family/c-cppbuiltin.c	(working copy)
@@ -65,6 +65,43 @@ static void builtin_define_float_constan
 					    const char *,
 					    tree);
 
+/* Return true if MODE provides a fast multiply/add (FMA) builtin function.
+   Originally this function used the fma optab, but that doesn't work with
+   -save-temps, so just rely on the HAVE_fma macros for the stnadard floating
+   point types.  */
+
+static bool
+mode_has_fma (enum machine_mode mode)
+{
+  switch (mode)
+    {
+#ifdef HAVE_fmasf4
+    case SFmode:
+      return !!HAVE_fmasf4;
+#endif
+
+#ifdef HAVE_fmadf4
+    case DFmode:
+      return !!HAVE_fmadf4;
+#endif
+
+#ifdef HAVE_fmaxf4
+    case XFmode:
+      return !!HAVE_fmaxf4;
+#endif
+
+#ifdef HAVE_fmatf4
+    case TFmode:
+      return !!HAVE_fmatf4;
+#endif
+
+    default:
+      break;
+    }
+
+  return false;
+}
+
 /* Define NAME with value TYPE size_unit.  */
 static void
 builtin_define_type_sizeof (const char *name, tree type)


-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meissner@linux.vnet.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]