public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19449] New: __builtin_constant_p cannot resolve to const when optimizing
@ 2005-01-14 19:11 eplondke at gmail dot com
2005-01-14 19:14 ` [Bug c/19449] " ian at airs dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: eplondke at gmail dot com @ 2005-01-14 19:11 UTC (permalink / raw)
To: gcc-bugs
Given the following code:
#define SHIFTLEFT(a,b) __builtin_choose_expr(__builtin_constant_p(b), \
((a) << (b)), \
((a) << (MIN(31,MAX(-31,(b))))))
int foo(int a, int b) { return SHIFTLEFT (a, b); }
the compiler will error:
gcc -O4 gcctest.c
gcctest.c: In function `foo':
gcctest.c:5: error: first argument to __builtin_choose_expr not a constant
According to the documentation to __builtin_constant_p, it should resolve
to 0 if the compiler cannot prove that the argument is a constant.
--
Summary: __builtin_constant_p cannot resolve to const when
optimizing
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: eplondke at gmail dot com
CC: eplondke at gmail dot com,gcc-bugs at gcc dot gnu dot
org
GCC build triplet: i686-pc-cygwin
GCC host triplet: i686-pc-cygwin
GCC target triplet: arm-unknown-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing
2005-01-14 19:11 [Bug c/19449] New: __builtin_constant_p cannot resolve to const when optimizing eplondke at gmail dot com
@ 2005-01-14 19:14 ` ian at airs dot com
2005-01-14 19:22 ` eplondke at gmail dot com
2005-01-14 19:26 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: ian at airs dot com @ 2005-01-14 19:14 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing
2005-01-14 19:11 [Bug c/19449] New: __builtin_constant_p cannot resolve to const when optimizing eplondke at gmail dot com
2005-01-14 19:14 ` [Bug c/19449] " ian at airs dot com
@ 2005-01-14 19:22 ` eplondke at gmail dot com
2005-01-14 19:26 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: eplondke at gmail dot com @ 2005-01-14 19:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From eplondke at gmail dot com 2005-01-14 19:22 -------
Created an attachment (id=7961)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7961&action=view)
Test case as a file.
Test case as a file.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing
2005-01-14 19:11 [Bug c/19449] New: __builtin_constant_p cannot resolve to const when optimizing eplondke at gmail dot com
2005-01-14 19:14 ` [Bug c/19449] " ian at airs dot com
2005-01-14 19:22 ` eplondke at gmail dot com
@ 2005-01-14 19:26 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-14 19:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-14 19:26 -------
The problem is the __builtin_constant_p is delayed for evalutation until optimizations are run but
__builtin_choose_expr needs an answer right away.
What we could do is for when processing the first argument of __builtin_choose_expr, say we are not in
a function.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
GCC build triplet|i686-pc-cygwin |
GCC host triplet|i686-pc-cygwin |
GCC target triplet|arm-unknown-elf |
Keywords| |rejects-valid
Last reconfirmed|0000-00-00 00:00:00 |2005-01-14 19:26:10
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-01-14 19:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-14 19:11 [Bug c/19449] New: __builtin_constant_p cannot resolve to const when optimizing eplondke at gmail dot com
2005-01-14 19:14 ` [Bug c/19449] " ian at airs dot com
2005-01-14 19:22 ` eplondke at gmail dot com
2005-01-14 19:26 ` pinskia at gcc dot gnu dot org
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).