}
goto done;
}
+ else if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
else
{
/* We cannot (easily) change the type of the copy if it is a storage
/* Transform bcmp (a, b, len) into memcmp (a, b, len). */
gimple *stmt = gsi_stmt (*gsi);
+ if (!gimple_vuse (stmt) && gimple_in_ssa_p (cfun))
+ return false;
tree a = gimple_call_arg (stmt, 0);
tree b = gimple_call_arg (stmt, 1);
tree len = gimple_call_arg (stmt, 2);
len) into memmove (dest, src, len). */
gimple *stmt = gsi_stmt (*gsi);
+ if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
tree src = gimple_call_arg (stmt, 0);
tree dest = gimple_call_arg (stmt, 1);
tree len = gimple_call_arg (stmt, 2);
/* Transform bzero (dest, len) into memset (dest, 0, len). */
gimple *stmt = gsi_stmt (*gsi);
+ if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
tree dest = gimple_call_arg (stmt, 0);
tree len = gimple_call_arg (stmt, 1);
return true;
}
+ if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
+
if (! tree_fits_uhwi_p (len))
return false;
if ((!INTEGRAL_TYPE_P (etype)
&& !POINTER_TYPE_P (etype))
|| TREE_CODE (etype) == BITINT_TYPE)
- return NULL_TREE;
+ return false;
if (! var_decl_component_p (var))
- return NULL_TREE;
+ return false;
length = tree_to_uhwi (len);
if (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (etype)) != length
|| (GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (etype))
!= GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (etype)))
|| get_pointer_alignment (dest) / BITS_PER_UNIT < length)
- return NULL_TREE;
+ return false;
if (length > HOST_BITS_PER_WIDE_INT / BITS_PER_UNIT)
- return NULL_TREE;
+ return false;
if (!type_has_mode_precision_p (etype))
etype = lang_hooks.types.type_for_mode (SCALAR_INT_TYPE_MODE (etype),
return false;
}
- if (!len)
+ if (!len || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
return false;
len = fold_convert_loc (loc, size_type_node, len);
/* OK transform into builtin memcpy. */
tree fn = builtin_decl_implicit (BUILT_IN_MEMCPY);
- if (!fn)
+ if (!fn || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
return false;
len = fold_convert_loc (loc, size_type_node, len);
return true;
}
- if (!integer_zerop (c))
+ if (!integer_zerop (c) || (!gimple_vuse (stmt) && gimple_in_ssa_p (cfun)))
return false;
/* Transform strrchr (s, 0) to strchr (s, 0) when optimizing for size. */
return true;
}
+ if (!gimple_vuse (stmt) && gimple_in_ssa_p (cfun))
+ return false;
+
/* Transform strstr (x, "c") into strchr (x, 'c'). */
if (q[1] == '\0')
{
if (!optimize_bb_for_speed_p (gimple_bb (stmt)))
return false;
+ if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
+
/* See if we can store by pieces into (dst + strlen(dst)). */
tree newdst;
tree strlen_fn = builtin_decl_implicit (BUILT_IN_STRLEN);
tree fn;
const char *p;
-
p = c_getstr (src);
/* If the SRC parameter is "", return DEST. */
if (p && *p == '\0')
if (! tree_fits_uhwi_p (size) || ! integer_all_onesp (size))
return false;
+ if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
+
/* If __builtin_strcat_chk is used, assume strcat is available. */
fn = builtin_decl_explicit (BUILT_IN_STRCAT);
if (!fn)
/* If the replacement _DECL isn't initialized, don't do the
transformation. */
- if (!fn)
+ if (!fn || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
return false;
/* Otherwise, emit a call to strcat. */
return true;
}
+ if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
+
if (! integer_all_onesp (size))
{
tree src_len = c_strlen (src, 1);
return true;
}
+ if (!gimple_vuse (stmt) && gimple_in_ssa_p (cfun))
+ return false;
+
/* Initially set to the number of characters, including the terminating
nul if each array has one. LENx == strnlen (Sx, LENx) implies that
the array Sx is not terminated by a nul.
const char *p = c_getstr (arg0);
if (p != NULL)
{
- if (!fn_fputc)
+ if (!fn_fputc || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
return false;
gimple *repl
return false;
/* New argument list transforming fputs(string, stream) to
fwrite(string, 1, len, stream). */
- if (!fn_fwrite)
+ if (!fn_fwrite || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
return false;
gimple *repl
}
}
+ if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
+
tree maxlen = get_maxval_strlen (len, SRK_INT_VALUE);
if (! integer_all_onesp (size)
&& !known_lower (stmt, len, size)
return true;
}
+ if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
+
tree maxlen = get_maxval_strlen (src, SRK_STRLENMAX);
if (! integer_all_onesp (size))
{
/* If __builtin_st{r,p}ncpy_chk is used, assume st{r,p}ncpy is available. */
fn = builtin_decl_explicit (fcode == BUILT_IN_STPNCPY_CHK && !ignore
? BUILT_IN_STPNCPY : BUILT_IN_STRNCPY);
- if (!fn)
+ if (!fn || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
return false;
gcall *repl = gimple_build_call (fn, 3, dest, src, len);
tree src = gimple_call_arg (stmt, 1);
tree fn, lenp1;
+ if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
+
/* If the result is unused, replace stpcpy with strcpy. */
if (gimple_call_lhs (stmt) == NULL_TREE)
{
available. */
fn = builtin_decl_explicit (fcode == BUILT_IN_VSNPRINTF_CHK
? BUILT_IN_VSNPRINTF : BUILT_IN_SNPRINTF);
- if (!fn)
+ if (!fn || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
return false;
/* Replace the called function and the first 5 argument by 3 retaining
/* If __builtin_{,v}sprintf_chk is used, assume {,v}sprintf is available. */
fn = builtin_decl_explicit (fcode == BUILT_IN_VSPRINTF_CHK
? BUILT_IN_VSPRINTF : BUILT_IN_SPRINTF);
- if (!fn)
+ if (!fn || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
return false;
/* Replace the called function and the first 4 argument by 2 retaining
return false;
tree fn = builtin_decl_implicit (BUILT_IN_STRCPY);
- if (!fn)
+ if (!fn || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
return false;
/* If the format doesn't contain % args or %%, use strcpy. */
tree orig = NULL_TREE;
const char *fmt_str = NULL;
- if (gimple_call_num_args (stmt) > 4)
+ if (gimple_call_num_args (stmt) > 4
+ || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
return false;
if (gimple_call_num_args (stmt) == 4)
if (!init_target_chars ())
return false;
+ if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
+
/* If the format doesn't contain % args or %%, use strcpy. */
if (strchr (fmt_str, target_percent) == NULL)
{
if (gimple_call_lhs (stmt) != NULL_TREE)
return false;
+ if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
+
/* Check whether the format is a literal string constant. */
fmt_str = c_getstr (fmt);
if (fmt_str == NULL)
tree arg = gimple_call_arg (stmt, 0);
tree size = gimple_call_arg (stmt, 1);
+ if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+ return false;
+
if (operand_equal_p (arg, null_pointer_node, 0))
{
tree fn_malloc = builtin_decl_implicit (BUILT_IN_MALLOC);