This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/38789] [4.4 Regression] __builtin_constant_p appears to evaluate to true for non-constant arguments.
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Jan 2009 12:42:54 -0000
- Subject: [Bug tree-optimization/38789] [4.4 Regression] __builtin_constant_p appears to evaluate to true for non-constant arguments.
- References: <bug-38789-7151@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #7 from jakub at gcc dot gnu dot org 2009-01-16 12:42 -------
The correct testcase is IMHO:
void
baz (int v)
{
unsigned a = (v == 1) ? 1 : 2;
if (__builtin_constant_p (a))
asm volatile ("# constant %0" :: "i" (a));
else
asm volatile ("# register %0" :: "r" (a));
}
For non-constant a using "i" constraint is wrong. This fails since
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134833
I guess handling BUILT_IN_CONSTANT_P the same as BUILT_IN_OBJECT_SIZE in
record_temporary_equivalences_from_stmts_at_dest
could do the trick.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38789