summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>1999-12-15 20:56:58 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>1999-12-15 20:56:58 +0000
commitf6326164d16bbdacbf87a11b5a6b768da2502abb (patch)
tree18d9c146d9ba14245e6cb2304f543a4a820ae3f0
parent089010c6015faf7a8046443e0c072249fad477c8 (diff)
downloadppe42-gcc-f6326164d16bbdacbf87a11b5a6b768da2502abb.tar.gz
ppe42-gcc-f6326164d16bbdacbf87a11b5a6b768da2502abb.zip
* builtins.c (expand_builtin_mathfn): Make sure not to expand the
argument more than once. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@30963 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/builtins.c9
2 files changed, 13 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5e8cfedadd0..0462e45f374 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+1999-12-15 Mark Mitchell <mark@codesourcery.com>
+
+ * builtins.c (expand_builtin_mathfn): Make sure not to expand the
+ argument more than once.
+
1999-12-15 Jason Merrill <jason@casey.cygnus.com>
* stmt.c (expand_decl): Expand upper bound of a dynamic array.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index ffc84fd9ccd..f03a53f864c 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -1182,9 +1182,16 @@ expand_builtin_mathfn (exp, target, subtarget)
&& TREE_CODE (TREE_VALUE (arglist)) != PARM_DECL)
{
exp = copy_node (exp);
- arglist = copy_node (arglist);
TREE_OPERAND (exp, 1) = arglist;
+ /* Wrap the computation of the argument in a SAVE_EXPR. That
+ way, if we need to expand the argument again (as in the
+ flag_errno_math case below where we cannot directly set
+ errno), we will not perform side-effects more than once.
+ Note that here we're mutating the original EXP as well as the
+ copy; that's the right thing to do in case the original EXP
+ is expanded later. */
TREE_VALUE (arglist) = save_expr (TREE_VALUE (arglist));
+ arglist = copy_node (arglist);
}
op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);
OpenPOWER on IntegriCloud