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 folding of builtin frexp


On 2/22/07, Kaveh R. GHAZI <ghazi@caip.rutgers.edu> wrote:
This patch folds builtin frexp where thet first argument is constant.

Tested on sparc-sun-solaris2.10, no regressions.

Okay for mainline?

This is ok with the change below


                Thanks,
                --Kaveh


2007-02-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>


        * builtins.c (fold_builtin_frexp): New.
        (fold_builtin_2): Use it.

testsuite:
        * gcc.dg/torture/builtin-frexp-1.c: New test.

diff -rup orig/egcc-SVN20070220/gcc/builtins.c egcc-SVN20070220/gcc/builtins.c
--- orig/egcc-SVN20070220/gcc/builtins.c        2007-02-20 20:02:30.000000000 -0500
+++ egcc-SVN20070220/gcc/builtins.c     2007-02-21 21:50:19.870945237 -0500
@@ -9017,6 +9017,63 @@ fold_builtin_carg (tree arg, tree type)
   return NULL_TREE;
 }

+/* Fold a call to builtin frexp, we can assume the base is 2.  */
+
+static tree
+fold_builtin_frexp (tree arg0, tree arg1, tree rettype)
+{
+  if (validate_arg (arg0, REAL_TYPE) && validate_arg (arg1, POINTER_TYPE))
+    {
+      STRIP_NOPS (arg0);
+
+      if (TREE_CODE (arg0) == REAL_CST && ! TREE_OVERFLOW (arg0))
+        {

if (!validate_arg (arg0, REAL_TYPE) || !validate_arg (arg1, POINTER_TYPE)) return NULL_TREE;

STRIP_NOPS (arg0);

if (!(TREE_CODE (arg0) == REAL_CST && ! TREE_OVERFLOW (arg0)))
 return NULL_TREE;

...

avoids unnecessary large indents.

Thanks,
Richard.


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