public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/48973] New: Inliner bug with one-bit (1-bit) bitfield
@ 2011-05-12  1:43 arthur.j.odwyer at gmail dot com
  2011-05-12  7:30 ` [Bug tree-optimization/48973] [4.3/4.4/4.5/4.6/4.7 Regression] " jakub at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: arthur.j.odwyer at gmail dot com @ 2011-05-12  1:43 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Inliner bug with one-bit (1-bit) bitfield
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: arthur.j.odwyer@gmail.com


Created attachment 24231
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24231
Output of "ajo-gcc -w -O1 -finline-small-functions test.c -v"

This reproduces for me with svn revision 173589 (2011-05-09). Since this
reproduces all the way back to 4.4, it *must* be a duplicate of *something*,
but I didn't find anything likely-looking in a Bugzilla search. I'm on Ubuntu
10.10, x86-64.

cat >test.c <<EOF
struct S0 {
   signed f0 : 1;
} g_72 = {0}; 
int f5 = -1;
void func_46(int f4) {
    g_72.f0 = (f5 & 1) > 0;
}
int main() {
    func_46(-1);
    printf("%x\n", (unsigned int)(g_72.f0));
    return 0;
}
EOF
gcc -w -O1 test.c -o a.out ; ./a.out
gcc -w -O2 test.c -o a.out ; ./a.out

REDUCED: gcc -w -O1 -finline-small-functions test.c -o a.out ; ./a.out

With -O1 the output is "ffffffff". With -O2 the output is "1". g_72.f0 should
evaluate to -1, and then casting that to (unsigned int) should always yield
0xffffffff regardless of optimization level. This looks to me like an inliner
bug.

In gcc 4.4.5 and 4.5.1, the bug also reproduces when you use "f4" instead of
"f5" inside func_46(). In trunk, you need to use a global variable to see the
bug.

This test case is reduced from the output of Csmith 2.1.0 (git hash 541a6480,
https://github.com/csmith-project/csmith/), using the following command line:
csmith --no-paranoid --no-longlong --no-pointers --arrays --no-jumps --consts
--no-volatiles --checksum --no-divs --no-muls --bitfields --packed-struct -s
1281232940


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

end of thread, other threads:[~2011-07-21  9:40 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-12  1:43 [Bug tree-optimization/48973] New: Inliner bug with one-bit (1-bit) bitfield arthur.j.odwyer at gmail dot com
2011-05-12  7:30 ` [Bug tree-optimization/48973] [4.3/4.4/4.5/4.6/4.7 Regression] " jakub at gcc dot gnu.org
2011-05-12  8:13 ` jakub at gcc dot gnu.org
2011-05-12  8:49 ` jakub at gcc dot gnu.org
2011-05-12  9:12 ` jakub at gcc dot gnu.org
2011-05-12  9:26 ` jakub at gcc dot gnu.org
2011-05-12 10:26 ` [Bug middle-end/48973] " rguenth at gcc dot gnu.org
2011-05-12 11:18 ` jakub at gcc dot gnu.org
2011-05-12 11:48 ` jakub at gcc dot gnu.org
2011-05-12 12:33 ` rguenth at gcc dot gnu.org
2011-05-23 10:12 ` jakub at gcc dot gnu.org
2011-05-23 10:48 ` jakub at gcc dot gnu.org
2011-05-23 11:15 ` [Bug middle-end/48973] [4.3/4.4/4.5 " jakub at gcc dot gnu.org
2011-06-27 10:46 ` rguenth at gcc dot gnu.org
2011-06-27 15:21 ` rguenth at gcc dot gnu.org
2011-07-19 12:50 ` [Bug middle-end/48973] [4.4/4.5 " jakub at gcc dot gnu.org
2011-07-19 19:29 ` jakub at gcc dot gnu.org
2011-07-19 19:54 ` jakub at gcc dot gnu.org
2011-07-21  9:40 ` jakub at gcc dot gnu.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).