This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Testcase for optimizer bug i686-pc-linux-gnulibc1
- To: "Karl G nter W nsch" <Karl dot Guenter dot Wuensch at neuss dot netsurf dot de>
- Subject: Re: Testcase for optimizer bug i686-pc-linux-gnulibc1
- From: Jim Wilson <wilson at cygnus dot com>
- Date: Tue, 28 Apr 1998 19:04:15 -0700
- cc: "egcs-bugs at cygnus dot com" <egcs-bugs at cygnus dot com>
The builtin memset was evaluating its arguments more than once in some
cases. Here is a patch.
1998-04-28 Jim Wilson <wilson@cygnus.com>
* expr.c (expand_builtin, case BUILT_IN_MEMSET): Break if either
val or len has TREE_SIDE_EFFECTS set.
Index: expr.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/expr.c,v
retrieving revision 1.48
diff -p -r1.48 expr.c
*** expr.c 1998/04/16 23:56:03 1.48
--- expr.c 1998/04/29 02:01:45
*************** expand_builtin (exp, target, subtarget,
*** 8609,8614 ****
--- 8609,8623 ----
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;