public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/38789]  New: __builtin_constant_p appears to eveluate to true for non-constant arguments.
@ 2009-01-09 21:40 daney at gcc dot gnu dot org
  2009-01-09 21:45 ` [Bug tree-optimization/38789] " pinskia at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: daney at gcc dot gnu dot org @ 2009-01-09 21:40 UTC (permalink / raw)
  To: gcc-bugs

gcc (GCC) 4.4.0 20090109 (experimental) [trunk revision 143212]

On x86_64-unknown-linux-gnu (FC9)

Configured as: ../trunk/configure --prefix=/home/ddaney/gccsvn/native-install
--disable-multilib --enable-languages=c

Consider the following program:

---foo.c--------8<----------------
void bar(int v)
{
        unsigned a;

        a = (v == 1) ? 1 : 2;

        if (__builtin_constant_p(a)) {
                asm volatile ("you lose. %0" : : "ir" (a));
        } else {
                asm volatile ("you win. %0" : : "ir" (a));
        }
}
--------------8<----------------
$ gcc -O2 -S foo.c
$ cat foo.s
        .file   "foo.c"
        .text
        .p2align 4,,15
.globl bar
        .type   bar, @function
bar:
.LFB0:
        .cfi_startproc
        xorl    %eax, %eax
        cmpl    $1, %edi
        setne   %al
        addl    $1, %eax
#APP
# 9 "foo.c" 1
        you lose. %eax
# 0 "" 2
#NO_APP
        ret
        .cfi_endproc
.LFE0:
        .size   bar, .-bar
        .ident  "GCC: (GNU) 4.4.0 20090109 (experimental) [trunk revision
143212]"
        .section        .note.GNU-stack,"",@progbits

It emits the asm from the __builtin_constant_p branch of the if statement.

Initial analysis points to VRP as being the problem.

For the system gcc (gcc (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)) it work
correctly.


-- 
           Summary: __builtin_constant_p appears to eveluate to true for
                    non-constant arguments.
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: daney at gcc dot gnu dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38789


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2009-01-30 17:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-09 21:40 [Bug tree-optimization/38789] New: __builtin_constant_p appears to eveluate to true for non-constant arguments daney at gcc dot gnu dot org
2009-01-09 21:45 ` [Bug tree-optimization/38789] " pinskia at gcc dot gnu dot org
2009-01-09 21:51 ` [Bug tree-optimization/38789] [4.4 Regression] " rguenth at gcc dot gnu dot org
2009-01-09 21:55 ` daney at gcc dot gnu dot org
2009-01-09 21:57 ` pinskia at gcc dot gnu dot org
2009-01-09 22:00 ` daney at gcc dot gnu dot org
2009-01-09 22:57 ` rguenth at gcc dot gnu dot org
2009-01-09 23:50 ` rguenth at gcc dot gnu dot org
2009-01-15 15:56 ` [Bug tree-optimization/38789] [4.4 Regression] __builtin_constant_p appears to evaluate " rguenth at gcc dot gnu dot org
2009-01-16 12:43 ` jakub at gcc dot gnu dot org
2009-01-16 12:49 ` jakub at gcc dot gnu dot org
2009-01-16 15:01 ` jakub at gcc dot gnu dot org
2009-01-16 15:03 ` jakub at gcc dot gnu dot org
2009-01-26 10:22 ` rguenth at gcc dot gnu dot org
2009-01-30 17:47 ` hjl 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).