[Bug middle-end/46647] Can't inline memset with -1
hjl.tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Nov 24 22:22:00 GMT 2010
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46647
--- Comment #9 from H.J. Lu <hjl.tools at gmail dot com> 2010-11-24 22:11:03 UTC ---
(In reply to comment #8)
> I'd prefer to replace the host_integerp call in that routine with
> TREE_CODE (...) == INTEGER_CST check. While currently callers check it as
> well, it isn't too expensive and makes it more robust.
/* Cast a target constant CST to target CHAR and if that value fits into
host char type, return zero and put that value into variable pointed to by
P. */
static int
target_char_cast (tree cst, char *p)
It is supposed to be called on integer constant. Adding a check
shouldn't be too bad:
diff --git a/gcc/builtins.c b/gcc/builtins.c
index c9e8e68..a90bf2f 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -630,11 +630,11 @@ target_char_cast (tree cst, char *p)
{
unsigned HOST_WIDE_INT val, hostval;
- if (!host_integerp (cst, 1)
+ if (TREE_CODE (cst) != INTEGER_CST
|| CHAR_TYPE_SIZE > HOST_BITS_PER_WIDE_INT)
return 1;
- val = tree_low_cst (cst, 1);
+ val = TREE_INT_CST_LOW (cst);
if (CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT)
val &= (((unsigned HOST_WIDE_INT) 1) << CHAR_TYPE_SIZE) - 1;
More information about the Gcc-bugs
mailing list