aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJim Wilson <wilson@cygnus.com>1998-04-28 19:12:47 +0000
committerJim Wilson <wilson@gcc.gnu.org>1998-04-28 12:12:47 -0700
commitbf931ec8298555022f74a00767dd00007a41cbf4 (patch)
tree74878aa40ab4948ceb52b8d6decea2af5e878b6a /gcc
parent2cea586a7e8f81bba8967a75701691444d9e9531 (diff)
downloadgcc-bf931ec8298555022f74a00767dd00007a41cbf4.zip
gcc-bf931ec8298555022f74a00767dd00007a41cbf4.tar.gz
gcc-bf931ec8298555022f74a00767dd00007a41cbf4.tar.bz2
Fix x86 memset bug, reported by Karl Guenter Wuensch.
* expr.c (expand_builtin, case BUILT_IN_MEMSET): Break if either val or len has TREE_SIDE_EFFECTS set. From-SVN: r19471
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog3
-rw-r--r--gcc/expr.c9
2 files changed, 12 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2a77dca..ca79fe8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,8 @@
Tue Apr 28 17:53:33 1998 Jim Wilson <wilson@cygnus.com>
+ * expr.c (expand_builtin, case BUILT_IN_MEMSET): Break if either
+ val or len has TREE_SIDE_EFFECTS set.
+
* sparc.md (mulsidi3): Call const v8plus and v8plus routines.
(mulsidi3_v8plus, const_mulsidi3_v8plus): Delete asterisk from name.
(smuldi3_highpart): Call const v8plus routine.
diff --git a/gcc/expr.c b/gcc/expr.c
index 8473181..c094a0f 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -8609,6 +8609,15 @@ expand_builtin (exp, target, subtarget, mode, ignore)
if (dest_align == 0)
break;
+ /* If the arguments have side-effects, then we can only evaluate
+ them at most once. The following code evaluates them twice if
+ they are not constants because we break out to expand_call
+ in that case. They can't be constants if they have side-effects
+ so we can check for that first. Alternatively, we could call
+ save_expr to make multiple evaluation safe. */
+ if (TREE_SIDE_EFFECTS (val) || TREE_SIDE_EFFECTS (len))
+ break;
+
/* If VAL is not 0, don't do this operation in-line. */
if (expand_expr (val, NULL_RTX, VOIDmode, 0) != const0_rtx)
break;