public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61531] New: Optimizer completely removes some bitset code
@ 2014-06-17 7:05 Ulrich.Windl at rz dot uni-regensburg.de
2014-06-17 7:12 ` [Bug c++/61531] " Ulrich.Windl at rz dot uni-regensburg.de
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Ulrich.Windl at rz dot uni-regensburg.de @ 2014-06-17 7:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61531
Bug ID: 61531
Summary: Optimizer completely removes some bitset code
Product: gcc
Version: 4.3.4
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: Ulrich.Windl at rz dot uni-regensburg.de
I wrote a simple test code for <bitset> that the default optimization complete
removes. Only -O0 keept the code. However the default code should output. Thus
I consider the optimization bad. Preprocessed input will follow, but here is
the basic test:
---
~/src/C++/bitsettest> cat bstest.cc
#include <iostream>
#include <bitset>
int main(int argc, char *argv[])
{
std::bitset<32> b;
#if 0
std::cout << "size " << b.size() << std::endl;
#endif
b.set(2);
if (b.test(2))
std::cout << "set 2" << std::endl;
if (b[3])
std::cout << "set 3" << std::endl;
return 0;
}
~/src/C++/bitsettest> make
g++ -Wall -Wextra -Wshadow -pipe -O2 -g --save-temps -c -o bstest.o
bstest.cc
g++: warning: -pipe ignored because -save-temps specified
bstest.cc:4: warning: unused parameter ‘argc’
bstest.cc:4: warning: unused parameter ‘argv’
g++ -o bstest bstest.o
~/src/C++/bitsettest>
(gdb) disassemble /m main
Dump of assembler code for function main(int, char**):
4 int main(int argc, char *argv[])
0x00000000004008b0 <+0>: sub $0x8,%rsp
5 {
6 std::bitset<32> b;
7
8 #if 0
9 std::cout << "size " << b.size() << std::endl;
10 #endif
11 b.set(2);
12 if (b.test(2))
13 std::cout << "set 2" << std::endl;
14 if (b[3])
15 std::cout << "set 3" << std::endl;
16 return 0;
17 }
0x00000000004008d2 <+34>: xor %eax,%eax
0x00000000004008d4 <+36>: add $0x8,%rsp
0x00000000004008d8 <+40>: retq
End of assembler dump.
---
>From gcc-bugs-return-454334-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 17 07:11:26 2014
Return-Path: <gcc-bugs-return-454334-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 9822 invoked by alias); 17 Jun 2014 07:11:26 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 9803 invoked by uid 48); 17 Jun 2014 07:11:21 -0000
From: "Ulrich.Windl at rz dot uni-regensburg.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/61531] Optimizer completely removes some bitset code
Date: Tue, 17 Jun 2014 07:11:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.3.4
X-Bugzilla-Keywords:
X-Bugzilla-Severity: major
X-Bugzilla-Who: Ulrich.Windl at rz dot uni-regensburg.de
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-61531-4-M2jnC09S1M@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-61531-4@http.gcc.gnu.org/bugzilla/>
References: <bug-61531-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-06/txt/msg01416.txt.bz2
Content-length: 209
https://gcc.gnu.org/bugzilla/show_bug.cgi?ida531
--- Comment #1 from Ulrich Windl <Ulrich.Windl at rz dot uni-regensburg.de> ---
Exact version of g++ is that of SLES11 SP3 for x86_64 (gcc-c++-4.3-62.198).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/61531] Optimizer completely removes some bitset code
2014-06-17 7:05 [Bug c++/61531] New: Optimizer completely removes some bitset code Ulrich.Windl at rz dot uni-regensburg.de
@ 2014-06-17 7:12 ` Ulrich.Windl at rz dot uni-regensburg.de
2014-06-17 7:20 ` Ulrich.Windl at rz dot uni-regensburg.de
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Ulrich.Windl at rz dot uni-regensburg.de @ 2014-06-17 7:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61531
--- Comment #2 from Ulrich Windl <Ulrich.Windl at rz dot uni-regensburg.de> ---
Created attachment 32948
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32948&action=edit
Preprocessed source (gzip compressed)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/61531] Optimizer completely removes some bitset code
2014-06-17 7:05 [Bug c++/61531] New: Optimizer completely removes some bitset code Ulrich.Windl at rz dot uni-regensburg.de
2014-06-17 7:12 ` [Bug c++/61531] " Ulrich.Windl at rz dot uni-regensburg.de
@ 2014-06-17 7:20 ` Ulrich.Windl at rz dot uni-regensburg.de
2014-06-17 7:22 ` schwab@linux-m68k.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Ulrich.Windl at rz dot uni-regensburg.de @ 2014-06-17 7:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61531
--- Comment #3 from Ulrich Windl <Ulrich.Windl at rz dot uni-regensburg.de> ---
Here's (for completeness) the code when I use "-O0":
~/src/C++/bitsettest> make
g++ -Wall -Wextra -Wshadow -O0 -g --save-temps -c -o bstest.o bstest.cc
bstest.cc:4: warning: unused parameter ‘argc’
bstest.cc:4: warning: unused parameter ‘argv’
g++ -o bstest bstest.o
~/src/C++/bitsettest> gdb bstest
GNU gdb (GDB) SUSE (7.5.1-0.7.29)
[...]
Dump of assembler code for function main(int, char**):
4 int main(int argc, char *argv[])
0x000000000040095e <+0>: push %rbp
0x000000000040095f <+1>: mov %rsp,%rbp
0x0000000000400962 <+4>: push %rbx
0x0000000000400963 <+5>: sub $0x38,%rsp
0x0000000000400967 <+9>: mov %edi,-0x34(%rbp)
0x000000000040096a <+12>: mov %rsi,-0x40(%rbp)
5 {
6 std::bitset<32> b;
0x000000000040096e <+16>: lea -0x30(%rbp),%rdi
0x0000000000400972 <+20>: callq 0x400a7a <std::bitset<32ul>::bitset()>
7
8 #if 0
9 std::cout << "size " << b.size() << std::endl;
10 #endif
11 b.set(2);
0x0000000000400977 <+25>: lea -0x30(%rbp),%rdi
0x000000000040097b <+29>: mov $0x1,%edx
0x0000000000400980 <+34>: mov $0x2,%esi
0x0000000000400985 <+39>: callq 0x400bf0
<std::bitset<32ul>::set(unsigned long, bool)>
12 if (b.test(2))
0x000000000040098a <+44>: lea -0x30(%rbp),%rdi
0x000000000040098e <+48>: mov $0x2,%esi
0x0000000000400993 <+53>: callq 0x400c28
<std::bitset<32ul>::test(unsigned long) const>
0x0000000000400998 <+58>: test %al,%al
0x000000000040099a <+60>: je 0x4009b8 <main(int, char**)+90>
13 std::cout << "set 2" << std::endl;
0x000000000040099c <+62>: mov $0x400d6d,%esi
0x00000000004009a1 <+67>: mov $0x602080,%edi
0x00000000004009a6 <+72>: callq 0x4007e0
<_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt>
0x00000000004009ab <+77>: mov %rax,%rdi
0x00000000004009ae <+80>: mov $0x400800,%esi
0x00000000004009b3 <+85>: callq 0x4007f0 <_ZNSolsEPFRSoS_E@plt>
14 if (b[3])
0x00000000004009b8 <+90>: lea -0x20(%rbp),%rdi
0x00000000004009bc <+94>: lea -0x30(%rbp),%rsi
0x00000000004009c0 <+98>: mov $0x3,%edx
0x00000000004009c5 <+103>: callq 0x400bbe
<std::bitset<32ul>::operator[](unsigned long)>
0x00000000004009ca <+108>: lea -0x20(%rbp),%rdi
0x00000000004009ce <+112>: callq 0x400a9c
<std::bitset<32ul>::reference::operator bool() const>
0x00000000004009d3 <+117>: mov %eax,%ebx
0x00000000004009d5 <+119>: lea -0x20(%rbp),%rdi
0x00000000004009d9 <+123>: callq 0x400a92
<std::bitset<32ul>::reference::~reference()>
0x00000000004009de <+128>: test %bl,%bl
0x00000000004009e0 <+130>: je 0x4009fe <main(int, char**)+160>
15 std::cout << "set 3" << std::endl;
0x00000000004009e2 <+132>: mov $0x400d73,%esi
0x00000000004009e7 <+137>: mov $0x602080,%edi
0x00000000004009ec <+142>: callq 0x4007e0
<_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt>
0x00000000004009f1 <+147>: mov %rax,%rdi
0x00000000004009f4 <+150>: mov $0x400800,%esi
0x00000000004009f9 <+155>: callq 0x4007f0 <_ZNSolsEPFRSoS_E@plt>
16 return 0;
0x00000000004009fe <+160>: mov $0x0,%eax
17 }
0x0000000000400a03 <+165>: add $0x38,%rsp
0x0000000000400a07 <+169>: pop %rbx
0x0000000000400a08 <+170>: leaveq
0x0000000000400a09 <+171>: retq
End of assembler dump.
(gdb)
>From gcc-bugs-return-454337-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jun 17 07:21:37 2014
Return-Path: <gcc-bugs-return-454337-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 15286 invoked by alias); 17 Jun 2014 07:21:37 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 15245 invoked by uid 48); 17 Jun 2014 07:21:33 -0000
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/61531] Optimizer completely removes some bitset code
Date: Tue, 17 Jun 2014 07:21:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.3.4
X-Bugzilla-Keywords:
X-Bugzilla-Severity: major
X-Bugzilla-Who: glisse at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-61531-4-Z8pUrQHkc0@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-61531-4@http.gcc.gnu.org/bugzilla/>
References: <bug-61531-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-06/txt/msg01419.txt.bz2
Content-length: 252
https://gcc.gnu.org/bugzilla/show_bug.cgi?ida531
--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> ---
4.3 is ancient and unsupported. Can you try to reproduce with 4.8 or later? (I
don't see it with 4.4, which is the oldest I have here)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/61531] Optimizer completely removes some bitset code
2014-06-17 7:05 [Bug c++/61531] New: Optimizer completely removes some bitset code Ulrich.Windl at rz dot uni-regensburg.de
2014-06-17 7:12 ` [Bug c++/61531] " Ulrich.Windl at rz dot uni-regensburg.de
2014-06-17 7:20 ` Ulrich.Windl at rz dot uni-regensburg.de
@ 2014-06-17 7:22 ` schwab@linux-m68k.org
2014-06-17 8:36 ` rguenth at gcc dot gnu.org
2014-06-17 13:57 ` Ulrich.Windl at rz dot uni-regensburg.de
4 siblings, 0 replies; 6+ messages in thread
From: schwab@linux-m68k.org @ 2014-06-17 7:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61531
Andreas Schwab <schwab@linux-m68k.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2014-06-17
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/61531] Optimizer completely removes some bitset code
2014-06-17 7:05 [Bug c++/61531] New: Optimizer completely removes some bitset code Ulrich.Windl at rz dot uni-regensburg.de
` (2 preceding siblings ...)
2014-06-17 7:22 ` schwab@linux-m68k.org
@ 2014-06-17 8:36 ` rguenth at gcc dot gnu.org
2014-06-17 13:57 ` Ulrich.Windl at rz dot uni-regensburg.de
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-17 8:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61531
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
It works for me.
> g++ t.C -O2
> ./a.out
set 2
this is with
> rpm -q gcc43-c++
gcc43-c++-4.3.4_20091019-0.22.17
> rpm -q --changelog gcc43-c++ | head
* Thu Nov 10 2011 rguenther@suse.com
- Fix altivec comparison builtins. [bnc#729378]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/61531] Optimizer completely removes some bitset code
2014-06-17 7:05 [Bug c++/61531] New: Optimizer completely removes some bitset code Ulrich.Windl at rz dot uni-regensburg.de
` (3 preceding siblings ...)
2014-06-17 8:36 ` rguenth at gcc dot gnu.org
@ 2014-06-17 13:57 ` Ulrich.Windl at rz dot uni-regensburg.de
4 siblings, 0 replies; 6+ messages in thread
From: Ulrich.Windl at rz dot uni-regensburg.de @ 2014-06-17 13:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61531
Ulrich Windl <Ulrich.Windl at rz dot uni-regensburg.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |INVALID
--- Comment #7 from Ulrich Windl <Ulrich.Windl at rz dot uni-regensburg.de> ---
As Richard Biener found out (and told me offline), the effect observed is not a
gcc issue, but a gdb issue (gdb 7.5.1 from SUSE):
While objdump -d displays the correct assembly code, gdb's "disassemble main"
also does, but gdb's "disassemble /m main" does not: It leaves the impression
that main() is just an empty routine. Sorry for causing trouble!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-06-17 13:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-17 7:05 [Bug c++/61531] New: Optimizer completely removes some bitset code Ulrich.Windl at rz dot uni-regensburg.de
2014-06-17 7:12 ` [Bug c++/61531] " Ulrich.Windl at rz dot uni-regensburg.de
2014-06-17 7:20 ` Ulrich.Windl at rz dot uni-regensburg.de
2014-06-17 7:22 ` schwab@linux-m68k.org
2014-06-17 8:36 ` rguenth at gcc dot gnu.org
2014-06-17 13:57 ` Ulrich.Windl at rz dot uni-regensburg.de
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).