+2003-05-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * builtins.c (expand_builtin_stpcpy): Only expand when the length
+ of the source string can be evaluated at compile-time.
+
2003-05-05 Aldy Hernandez <aldyh@redhat.com>
* testsuite/gcc.c-torture/compile/simd-6.c: New.
else
{
tree newarglist;
- tree len;
+ tree src, len;
/* If return value is ignored, transform stpcpy into strcpy. */
if (target == const0_rtx)
target, mode, EXPAND_NORMAL);
}
- len = c_strlen (TREE_VALUE (TREE_CHAIN (arglist)));
- if (len == 0)
+ /* Ensure we get an actual string who length can be evaluated at
+ compile-time, not an expression containing a string. This is
+ because the latter will potentially produce pessimized code
+ when used to produce the return value. */
+ src = TREE_VALUE (TREE_CHAIN (arglist));
+ if (! c_getstr (src) || ! (len = c_strlen (src)))
return 0;
len = fold (size_binop (PLUS_EXPR, len, ssize_int (1)));