Patchwork Fix PR46041, define fma macros if -save-temps

login
register
mail settings
Submitter Michael Meissner
Date Oct. 18, 2010, 8:04 p.m.
Message ID <20101018200440.GA16772@hungry-tiger.westford.ibm.com>
Download mbox | patch
Permalink /patch/68234/
State New
Headers show

Comments

Michael Meissner - Oct. 18, 2010, 8:04 p.m.
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.
Richard Henderson - Oct. 18, 2010, 8:09 p.m.
On 10/18/2010 01:04 PM, Michael Meissner wrote:
> 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.

Ok except,

> +   -save-temps, so just rely on the HAVE_fma macros for the stnadard floating

Typo.



r~

Patch

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)