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]

[tree-ssa] Folding of calls to builtin functions


This allows us to fold calls to builtin functions with constant
arguments.  This should be pretty rare so I'm not terribly concerned
about the call to copy_stmt.


       * tree-ssa-ccp.c (ccp_fold): Also handle folding of calls to
        builtin functions.

Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v
retrieving revision 1.1.2.58
diff -c -3 -p -r1.1.2.58 tree-ssa-ccp.c
*** tree-ssa-ccp.c	26 Feb 2003 01:14:42 -0000	1.1.2.58
--- tree-ssa-ccp.c	26 Feb 2003 23:07:29 -0000
*************** ccp_fold (stmt)
*** 731,736 ****
--- 731,749 ----
  	  && really_constant_p (op1))
  	return build (code, TREE_TYPE (rhs), op0, op1);
      }
+ 
+   /* We may be able to fold away calls to builtin functions if their
+      arguments are constants. */
+   else if (code == CALL_EXPR
+ 	   && TREE_CODE (TREE_OPERAND (rhs, 0)) == ADDR_EXPR
+ 	   && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (rhs, 0), 0))
+ 	       == FUNCTION_DECL)
+ 	   && DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (rhs, 0), 0)))
+     {
+       tree copy = copy_stmt (stmt);
+       replace_uses_in (copy);
+       retval = fold_builtin (get_rhs (copy));
+     }
    else





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