Patchwork fix builtin-math-2.c on fma targets

login
register
mail settings
Submitter Richard Henderson
Date Nov. 15, 2010, 11:53 p.m.
Message ID <4CE1C80D.1010401@redhat.com>
Download mbox | patch
Permalink /patch/71316/
State New
Headers show

Comments

Richard Henderson - Nov. 15, 2010, 11:53 p.m.
The existing test scans for the fma builtins remaining.  Unfortunately,
if fma is supported on the target we've already folded these to FMA_EXPR.

Fixed by adjusting the test case to make sure that (1) FMA_EXPR folds to
a constant, proving that (2) FMA_EXPR with overflowing constants tests
what we intend to test.

Tested on ia64-linux with all fma patches applied.  Committed.


r~
* gcc.dg/torture/builtin-math-2.c: Split out fma tests...
	* gcc.dg/torture/builtin-math-8.c: ... here.  New file.
	Use builtin_constant_p rather than scanning for builtin name.

Patch

Index: gcc.dg/torture/builtin-math-2.c
===================================================================
--- gcc.dg/torture/builtin-math-2.c	(revision 166777)
+++ gcc.dg/torture/builtin-math-2.c	(working copy)
@@ -184,18 +184,6 @@ 
   fool (__builtin_powl (__LDBL_MAX__, -3.5L));
   TESTIT2 (pow, 2.0, -0x1p50);
   
-  foof (__builtin_fmaf (__FLT_MAX__, __FLT_MAX__, 0.0F));
-  foof (__builtin_fmaf (__FLT_MAX__, 1.0F, __FLT_MAX__));
-  foof (__builtin_fmaf (__FLT_MIN__, __FLT_MIN__, 0.0F));
-  
-  foo (__builtin_fma (__DBL_MAX__, __DBL_MAX__, 0.0));
-  foo (__builtin_fma (__DBL_MAX__, 1.0, __DBL_MAX__));
-  foo (__builtin_fma (__DBL_MIN__, __DBL_MIN__, 0.0));
-  
-  fool (__builtin_fmal (__LDBL_MAX__, __LDBL_MAX__, 0.0L));
-  fool (__builtin_fmal (__LDBL_MAX__, 1.0L, __LDBL_MAX__));
-  fool (__builtin_fmal (__LDBL_MIN__, __LDBL_MIN__, 0.0L));
-
   /* The sqrt arg must be [0 ... Inf] inclusive.  */
   TESTIT (sqrt, -0.5);
   TESTIT (sqrt, -0.0);
@@ -351,9 +339,6 @@ 
 /* { dg-final { scan-tree-dump-times "powf" 13 "original" { target { ! { spu*-*-* } } } } } */
 /* { dg-final { scan-tree-dump-times "powf" 7 "original" { target { spu*-*-* } } } } */
 /* { dg-final { scan-tree-dump-times "powl" 13 "original" } } */
-/* { dg-final { scan-tree-dump-times "fma " 3 "original" } } */
-/* { dg-final { scan-tree-dump-times "fmaf" 3 "original" } } */
-/* { dg-final { scan-tree-dump-times "fmal" 3 "original" } } */
 /* { dg-final { scan-tree-dump-times "sqrt " 1 "original" } } */
 /* { dg-final { scan-tree-dump-times "sqrtf" 1 "original" } } */
 /* { dg-final { scan-tree-dump-times "sqrtl" 1 "original" } } */
Index: gcc.dg/torture/builtin-math-8.c
===================================================================
--- gcc.dg/torture/builtin-math-8.c	(revision 0)
+++ gcc.dg/torture/builtin-math-8.c	(revision 0)
@@ -0,0 +1,34 @@ 
+/* { dg-do link } */
+
+extern void link_error (void);
+
+int main()
+{
+  if (!__builtin_constant_p(1.0))
+    link_error ();
+  if (!__builtin_constant_p(__builtin_fma (1.0, 1.0, 1.0)))
+    link_error ();
+
+  if (__builtin_constant_p(__builtin_fmaf (__FLT_MAX__, __FLT_MAX__, 0.0F)))
+    link_error ();
+  if (__builtin_constant_p(__builtin_fmaf (__FLT_MAX__, 1.0F, __FLT_MAX__)))
+    link_error ();
+  if (__builtin_constant_p(__builtin_fmaf (__FLT_MIN__, __FLT_MIN__, 0.0F)))
+    link_error ();
+
+  if (__builtin_constant_p(__builtin_fma (__DBL_MAX__, __DBL_MAX__, 0.0)))
+    link_error ();
+  if (__builtin_constant_p(__builtin_fma (__DBL_MAX__, 1.0, __DBL_MAX__)))
+    link_error ();
+  if (__builtin_constant_p(__builtin_fma (__DBL_MIN__, __DBL_MIN__, 0.0)))
+    link_error ();
+
+  if (__builtin_constant_p(__builtin_fmal (__LDBL_MAX__, __LDBL_MAX__, 0.0L)))
+    link_error ();
+  if (__builtin_constant_p(__builtin_fmal (__LDBL_MAX__, 1.0L, __LDBL_MAX__)))
+    link_error ();
+  if (__builtin_constant_p(__builtin_fmal (__LDBL_MIN__, __LDBL_MIN__, 0.0L)))
+    link_error ();
+
+  return 0;
+}