public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18120] New: -O2 -funroll-loops causes bad loop behavior on fedora
@ 2004-10-23 1:06 anndirkvg at gmail dot com
2004-10-23 1:08 ` [Bug c++/18120] " anndirkvg at gmail dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: anndirkvg at gmail dot com @ 2004-10-23 1:06 UTC (permalink / raw)
To: gcc-bugs
The main loop in this code should loop from 'a' to 'z'. On gcc3.3.3 on fedora
with -O2 and -funroll-loops, it loops the correct number of times but the
key value alternates between 97 and 98.
Compile line:
g++ -o gccBug -O2 -funroll-loops main.cpp
Contents of main.cpp:
#include <stdio.h>
#define CP_ALPHA_STATE(x) (1<<((x)-'a'))
class GptoKeyState {
public:
GptoKeyState() {
for (int i=0; i< 256; ++i) {
_keyDown[i] = 0;
}
}
///
int IsDown(unsigned char key) const {
return _keyDown[key];
}
void SetDownKey(unsigned char key, int down) {
_keyDown[(unsigned int)key] = down;
}
///
void SetDown(unsigned char key, int down) {
_keyDown[(unsigned int)key] = down;
}
private:
int _keyDown[256];
};
int
main(int, char**)
{
GptoKeyState _keyState;
char key;
int status2 = 8;
for (key = 'a'; key<= 'z'; ++key) {
int keyDown;
printf("Testing %d\n", (int) key);
// the & can return a value greater than 1, we want a boolean
if (status2 & CP_ALPHA_STATE(key))
keyDown = 1;
else
keyDown = 0;
if (_keyState.IsDown((unsigned char)key) != keyDown) {
_keyState.SetDown((unsigned char)key, keyDown);
}
}
}
Results of g++ -v:
Reading specs from /usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --disable-libunwind-exceptions --with-system-zlib
--enable-__cxa_atexit --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
Output from generating ii file:
Reading specs from /usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --disable-libunwind-exceptions --with-system-zlib
--enable-__cxa_atexit --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/cc1plus -E -D__GNUG__=3 -quiet -v
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -D_GNU_SOURCE main.cpp
-funroll-loops -O2 main.ii
ignoring nonexistent directory "/usr/x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/3.3.3
/usr/include/c++/3.3.3/x86_64-redhat-linux
/usr/include/c++/3.3.3/backward
/usr/local/include
/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/include
/usr/include
End of search list.
/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/cc1plus -fpreprocessed main.ii
-quiet -dumpbase main.cpp -auxbase main -O2 -version -funroll-loops -o main.s
GNU C++ version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) (x86_64-redhat-linux)
compiled by GNU C version 3.3.3 20040412 (Red Hat Linux 3.3.3-7).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
as -V -Qy -o main.o main.s
GNU assembler version 2.15.90.0.3 (x86_64-redhat-linux) using BFD version
2.15.90.0.3 20040415
/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/collect2 --eh-frame-hdr -m
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o gccBug
/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/../../../../lib64/crt1.o
/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/../../../../lib64/crti.o
/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/crtbegin.o
-L/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3
-L/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/../../../../lib64
-L/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/../../.. -L/lib/../lib64
-L/usr/lib/../lib64 main.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/crtend.o
/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/../../../../lib64/crtn.o
I'll try and attach main.ii after submitting the bug.
Sorry if this isn't quite the right format, this is my first g++ bug.
-Dirk (reporting from Pixar Animation Studios software development group)
--
Summary: -O2 -funroll-loops causes bad loop behavior on fedora
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: anndirkvg at gmail dot com
CC: anndirkvg at gmail dot com,gcc-bugs at gcc dot gnu dot
org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18120
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/18120] -O2 -funroll-loops causes bad loop behavior on fedora
2004-10-23 1:06 [Bug c++/18120] New: -O2 -funroll-loops causes bad loop behavior on fedora anndirkvg at gmail dot com
@ 2004-10-23 1:08 ` anndirkvg at gmail dot com
2004-10-23 1:20 ` [Bug rtl-optimization/18120] " pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: anndirkvg at gmail dot com @ 2004-10-23 1:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From anndirkvg at gmail dot com 2004-10-23 01:08 -------
Created an attachment (id=7404)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7404&action=view)
This is the generated .ii file.
Hope this helps. We've stopped using unroll-loops with g++
so it's not critical for us, good to have fixed though.
Thanks-
Dirk
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18120
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/18120] -O2 -funroll-loops causes bad loop behavior on fedora
2004-10-23 1:06 [Bug c++/18120] New: -O2 -funroll-loops causes bad loop behavior on fedora anndirkvg at gmail dot com
2004-10-23 1:08 ` [Bug c++/18120] " anndirkvg at gmail dot com
@ 2004-10-23 1:20 ` pinskia at gcc dot gnu dot org
2004-10-23 16:22 ` bangerth at dealii dot org
2005-01-22 0:19 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-23 1:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-23 01:20 -------
Most likely this does not effect 3.4.0 or 4.0.0 at all because they both have new loop unrollers. (and if it
does effect them, then there is it is not a bug in the unroller but another part of GCC).
--
What |Removed |Added
----------------------------------------------------------------------------
Component|c++ |rtl-optimization
GCC target triplet| |x86_64-redhat-linux
Keywords| |wrong-code
Summary|-O2 -funroll-loops causes |-O2 -funroll-loops causes
|bad loop behavior on fedora |bad loop behavior on fedora
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18120
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/18120] -O2 -funroll-loops causes bad loop behavior on fedora
2004-10-23 1:06 [Bug c++/18120] New: -O2 -funroll-loops causes bad loop behavior on fedora anndirkvg at gmail dot com
2004-10-23 1:08 ` [Bug c++/18120] " anndirkvg at gmail dot com
2004-10-23 1:20 ` [Bug rtl-optimization/18120] " pinskia at gcc dot gnu dot org
@ 2004-10-23 16:22 ` bangerth at dealii dot org
2005-01-22 0:19 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2004-10-23 16:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-10-23 16:22 -------
Can you post the output you get from using -funroll-loops and without?
They look the same on my system, so I'm not sure what's wrong. (It's
not a fedora system, though, so that may be one of the reasons.)
Thanks
Wolfgang
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18120
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/18120] -O2 -funroll-loops causes bad loop behavior on fedora
2004-10-23 1:06 [Bug c++/18120] New: -O2 -funroll-loops causes bad loop behavior on fedora anndirkvg at gmail dot com
` (2 preceding siblings ...)
2004-10-23 16:22 ` bangerth at dealii dot org
@ 2005-01-22 0:19 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-22 0:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-22 00:16 -------
No feed back in 3 months (T-2 days).
--
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18120
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-01-22 0:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-23 1:06 [Bug c++/18120] New: -O2 -funroll-loops causes bad loop behavior on fedora anndirkvg at gmail dot com
2004-10-23 1:08 ` [Bug c++/18120] " anndirkvg at gmail dot com
2004-10-23 1:20 ` [Bug rtl-optimization/18120] " pinskia at gcc dot gnu dot org
2004-10-23 16:22 ` bangerth at dealii dot org
2005-01-22 0:19 ` 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).