public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* signed enum bug
@ 2005-02-25 21:35 Aaron Coleman
  2005-02-25 22:23 ` Eric Botcazou
  0 siblings, 1 reply; 2+ messages in thread
From: Aaron Coleman @ 2005-02-25 21:35 UTC (permalink / raw)
  To: gcc-bugs

[-- Attachment #1: Type: text/plain, Size: 952 bytes --]

[My first time at reporting, so please bear with me if I do something wrong...]
 
The compiler outputs a bg branch instruction when it should use a bgu. The cause seems to be related to having a negative value in the enumeration. If I just comment out the DummyValue1 line, the code is correct. It does this at any optimization level of 1 or higher, and I haven't figured out if there is a specific optimization I can turn off as a work around.
 
      add   %o0, -2, %o0
      cmp   %o0, 1
      .stabn 68,0,13,.LLM3-_Z13DummyFunction10tTestEnum2
.LLM3:
      .stabn 68,0,15,.LLM4-_Z13DummyFunction10tTestEnum2
.LLM4:
      bg    .LL2
      mov   0, %o0
      .stabn 68,0,16,.LLM5-_Z13DummyFunction10tTestEnum2
.LLM5:
      mov   2, %o0
.LL2:
.LLBE3:
.LLBE2:
      retl
      nop
 
 
 
Thanks,
Aaron Coleman
Software Engineering Manager
Lowrance Electronics, Inc.
12000 E Skelly Dr.
Tulsa, OK 74128
918-437-6881 x8551
 

[-- Attachment #2: test.ii --]
[-- Type: application/octet-stream, Size: 343 bytes --]

# 1 "test.cpp"
# 1 "/cygdrive/f/Projects/TestApp_Memory/Main//"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.cpp"

enum tTestEnum2
{
 DummyValue1 = -1,
 DummyValue2,
 DummyValue3,
 DummyValue4,
 DummyValue5,
};

int DummyFunction(tTestEnum2 Enum)
{
 long Ret = 0;

 if(Enum == DummyValue4 || Enum == DummyValue5)
  Ret = 2;

 return Ret;
}

[-- Attachment #3: output.txt --]
[-- Type: text/plain, Size: 1744 bytes --]

Reading specs from /compilers/sparc-elf/lib/gcc/sparc-elf/3.4.0/specs
Configured with: /gcc_src/gcc-3.4-20040317/configure --prefix=/compilers/sparc-elf --target=sparc-elf --enable-languages=c++ --with-newlib --enable-clocale=generic --enable-cxx-flags=-fno-exceptions --disable-hosted-libstdcxx
Thread model: single
gcc version 3.4.0 20040317 (prerelease)
 /compilers/sparc-elf/libexec/gcc/sparc-elf/3.4.0/cc1plus.exe -E -quiet -v -D__sparc_v8__ -D__sparc_v8__ test.cpp -mcpu=v8 -mcpu=v8 -mtune=v8 -mv8 -m32 -Werror -Wall -fworking-directory -O1 -o test.ii
ignoring nonexistent directory "/compilers/sparc-elf/lib/gcc/sparc-elf/3.4.0/../../../../include/c++/3.4.0/backward"
ignoring nonexistent directory "/compilers/sparc-elf/lib/gcc/sparc-elf/3.4.0/../../../../sparc-elf/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 /compilers/sparc-elf/lib/gcc/sparc-elf/3.4.0/../../../../include/c++/3.4.0
 /compilers/sparc-elf/lib/gcc/sparc-elf/3.4.0/../../../../include/c++/3.4.0/sparc-elf
 /compilers/sparc-elf/lib/gcc/sparc-elf/3.4.0/include
 /compilers/sparc-elf/lib/gcc/sparc-elf/3.4.0/../../../../sparc-elf/include
End of search list.
 /compilers/sparc-elf/libexec/gcc/sparc-elf/3.4.0/cc1plus.exe -fpreprocessed test.ii -mcpu=v8 -quiet -dumpbase test.cpp -mcpu=v8 -mtune=v8 -mv8 -m32 -auxbase-strip test.o -g -O1 -Werror -Wall -version -o test.s
GNU C++ version 3.4.0 20040317 (prerelease) (sparc-elf)
	compiled by GNU C version 3.3.1 (cygming special).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 /compilers/sparc-elf/lib/gcc/sparc-elf/3.4.0/../../../../sparc-elf/bin/as.exe -V -Qy -s -o test.o test.s
GNU assembler version 040202 (sparc-elf) using BFD version 040202 20040202

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

* Re: signed enum bug
  2005-02-25 21:35 signed enum bug Aaron Coleman
@ 2005-02-25 22:23 ` Eric Botcazou
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Botcazou @ 2005-02-25 22:23 UTC (permalink / raw)
  To: gcc-bugs; +Cc: Aaron Coleman

> The compiler outputs a bg branch instruction when it should use a bgu. The
> cause seems to be related to having a negative value in the enumeration.

Fixed in 3.4.4pre:

_Z13DummyFunction10tTestEnum2:
.LLFB2:
        !#PROLOGUE# 0
        !#PROLOGUE# 1
        add     %o0, -2, %o0
        cmp     %o0, 1
        bgu     .LL2
        mov     0, %g1
        mov     2, %g1
.LL2:
        retl
        mov     %g1, %o0
.LLFE2:
	.size	_Z13DummyFunction10tTestEnum2, .-_Z13DummyFunction10tTestEnum2
	.ident	"GCC: (GNU) 3.4.4 20050224 (prerelease)"

-- 
Eric Botcazou


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

end of thread, other threads:[~2005-02-25 16:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-25 21:35 signed enum bug Aaron Coleman
2005-02-25 22:23 ` Eric Botcazou

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).