* [Tiny patch] builtin_constant_p improvement.
@ 2000-08-03 13:18 Ralph Loader
2000-08-04 6:13 ` Jamie Lokier
0 siblings, 1 reply; 2+ messages in thread
From: Ralph Loader @ 2000-08-03 13:18 UTC (permalink / raw)
To: gcc
Hi,
The enclosed patch causes the following (recently posted) code to
return 1 when compiled as C code. (It already does when compiled as
C++). It removes an assumption that pointers can only be constant if
they are literals.
inline int f (const char *const s)
{
if (__builtin_constant_p (s))
return 1;
else
return 0;
}
int g ()
{
return f ("abc");
}
Ralph.
-------------------------------------
--- gcc/builtins.c~ Tue Jul 4 06:28:33 2000
+++ gcc/builtins.c Thu Aug 3 20:38:49 2000
@@ -1167,12 +1167,11 @@
/* If we aren't going to be running CSE or this expression
has side effects, show we don't know it to be a constant.
- Likewise if it's a pointer or aggregate type since in those
- case we only want literals, since those are only optimized
+ Likewise if it's an aggregate type, since in that
+ case we only want literals, since that is only optimized
when generating RTL, not later. */
if (TREE_SIDE_EFFECTS (arg) || cse_not_expected
- || AGGREGATE_TYPE_P (TREE_TYPE (arg))
- || POINTER_TYPE_P (TREE_TYPE (arg)))
+ || AGGREGATE_TYPE_P (TREE_TYPE (arg)))
return const0_rtx;
/* Otherwise, emit (constant_p_rtx (ARG)) and let CSE get a
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Tiny patch] builtin_constant_p improvement.
2000-08-03 13:18 [Tiny patch] builtin_constant_p improvement Ralph Loader
@ 2000-08-04 6:13 ` Jamie Lokier
0 siblings, 0 replies; 2+ messages in thread
From: Jamie Lokier @ 2000-08-04 6:13 UTC (permalink / raw)
To: Ralph Loader; +Cc: gcc
Just as well, because Glibc assumes this does work. See strlen,
<bits/string2.h>.
-- Jamie
Ralph Loader wrote:
> The enclosed patch causes the following (recently posted) code to
> return 1 when compiled as C code. (It already does when compiled as
> C++). It removes an assumption that pointers can only be constant if
> they are literals.
>
> inline int f (const char *const s)
> {
> if (__builtin_constant_p (s))
> return 1;
> else
> return 0;
> }
>
> int g ()
> {
> return f ("abc");
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-08-04 6:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-03 13:18 [Tiny patch] builtin_constant_p improvement Ralph Loader
2000-08-04 6:13 ` Jamie Lokier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).