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]

Re: [PATCH]: Add some more builtins opts for sqrt/cbrt


 > From: David Edelsohn <dje@watson.ibm.com>
 > 
 > 	builtin-power-1.c is failing on PowerPC.  On AIX I see the
 > following link failures in the log:
 > 
 > ld: 0711-317 ERROR: Undefined symbol: .link_failure_sqrt_sqrt
 > ld: 0711-317 ERROR: Undefined symbol: .link_failure_sqrt_cbrt
 > ld: 0711-317 ERROR: Undefined symbol: .link_failure_cbrt_sqrt

The problem here was that we were transforming into the wrong FP type,
i.e. pow vs powl.  The following patch seems to fix the problem in a
cross config to aix5.1 when visually scanning the assembly output.

David - Does it fix the failure you saw?

Meanwhile, I'm running a full regression test on solaris2.7.  Assuming
it fixes David's failure and passes regtest, ok for mainline?

		--Kaveh

PS: I indended to use `mathfn_built_in' to say "give me the mathfn
builtin for a particular FP type, e.g. float".  It doesn't appear to
do that exactly, so I'm not sure when it's ever correct to use
mathfn_built_in.



2004-03-27  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* builtins.c (fold_builtin): Don't use `mathfn_built_in' to lookup
	replacement builtin.

diff -rup orig/egcc-CVS20040327/gcc/builtins.c egcc-CVS20040327/gcc/builtins.c
--- orig/egcc-CVS20040327/gcc/builtins.c	Thu Mar 25 19:27:52 2004
+++ egcc-CVS20040327/gcc/builtins.c	Sat Mar 27 18:45:44 2004
@@ -6693,7 +6693,12 @@ fold_builtin (tree exp)
 	  /* Optimize sqrt(Nroot(x)) -> pow(x,1/(2*N)).  */
 	  if (flag_unsafe_math_optimizations && BUILTIN_ROOT_P (fcode))
 	    {
-	      tree powfn = mathfn_built_in (type, BUILT_IN_POW);
+	      tree powfn = (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_SQRT)
+		? implicit_built_in_decls[BUILT_IN_POW] :
+		(DECL_FUNCTION_CODE (fndecl) == BUILT_IN_SQRTF)
+		? implicit_built_in_decls[BUILT_IN_POWF] :
+		(DECL_FUNCTION_CODE (fndecl) == BUILT_IN_SQRTL)
+		? implicit_built_in_decls[BUILT_IN_POWL] : NULL_TREE;
 	      
 	      if (powfn)
 	        {
@@ -6761,7 +6766,12 @@ fold_builtin (tree exp)
              x is negative pow will error but cbrt won't.  */
 	  if (flag_unsafe_math_optimizations && BUILTIN_SQRT_P (fcode))
 	    {
-	      tree powfn = mathfn_built_in (type, BUILT_IN_POW);
+	      tree powfn = (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CBRT)
+		? implicit_built_in_decls[BUILT_IN_POW] :
+		(DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CBRTF)
+		? implicit_built_in_decls[BUILT_IN_POWF] :
+		(DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CBRTL)
+		? implicit_built_in_decls[BUILT_IN_POWL] : NULL_TREE;
 
 	      if (powfn)
 	        {


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