[Bug target/59343] New: miscompiled for loop in sh4 target (-Os)

2013-11-29 Thread gcc-bugzilla-f5d8 at theblacksun dot eu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59343

Bug ID: 59343
   Summary: miscompiled for loop in sh4 target (-Os)
   Product: gcc
   Version: 4.8.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc-bugzilla-f5d8 at theblacksun dot eu

Created attachment 31327
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31327&action=edit
miscompilation testcase

The attached testcase miscompiles on sh4 target if build with -Os

$ sh4-unknown-linux-gnu-g++ -Wall -Wextra -o for_loop_miscompile_O2 -O2
for_loop_miscompile.cpp
$ sh4-unknown-linux-gnu-g++ -Wall -Wextra -o for_loop_miscompile_Os -Os
for_loop_miscompile.cpp

target $ ./for_loop_miscompile_O2
teststring = 0x411068
teststring = 0x411068
target $ ./for_loop_miscompile_Os
teststring = 0x411068
teststring = 0x1


[Bug target/59343] miscompiled for loop in sh4 target (-Os)

2013-11-29 Thread gcc-bugzilla-f5d8 at theblacksun dot eu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59343

--- Comment #2 from gcc-bugzilla-f5d8 at theblacksun dot eu ---
Created attachment 31330
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31330&action=edit
assembler output from -O2


[Bug target/59343] miscompiled for loop in sh4 target (-Os)

2013-11-29 Thread gcc-bugzilla-f5d8 at theblacksun dot eu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59343

--- Comment #1 from gcc-bugzilla-f5d8 at theblacksun dot eu ---
Created attachment 31329
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31329&action=edit
assembler output from -Os


[Bug target/59343] miscompiled for loop in sh4 target (-Os)

2013-12-02 Thread gcc-bugzilla-f5d8 at theblacksun dot eu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59343

--- Comment #3 from gcc-bugzilla-f5d8 at theblacksun dot eu ---
Created attachment 31349
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31349&action=edit
Second failing testcase. Triggers in -O1 and -O2 too


[Bug target/59343] miscompiled for loop in sh4 target (-Os)

2013-12-02 Thread gcc-bugzilla-f5d8 at theblacksun dot eu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59343

gcc-bugzilla-f5d8 at theblacksun dot eu changed:

   What|Removed |Added

 Target||sh4-unknown-linux-gnu

--- Comment #4 from gcc-bugzilla-f5d8 at theblacksun dot eu ---
Using the second testcase the compiler also misbehaves:

$ sh4-unknown-linux-gnu-g++ -Wall -Wextra -static -o testcase2_O2 -O2
testcase2.cpp
$ sh4-unknown-linux-gnu-g++ -Wall -Wextra -static -o testcase2_O1 -O1
testcase2.cpp
$ sh4-unknown-linux-gnu-g++ -Wall -Wextra -static -o testcase2_O0 -O0
testcase2.cpp
$ sh4-unknown-linux-gnu-g++ -Wall -Wextra -static -o testcase2_Os -Os
testcase2.cpp

$ qemu-sh4 ./testcase2_00
flag1 is true... flag2?: 0

$ qemu-sh4 ./testcase2_01
flag1 is true... flag2?: 0
flag2 is true

$ qemu-sh4 ./testcase2_02
flag1 is true... flag2?: 0
flag2 is true

$ qemu-sh4 ./testcase2_0s
flag1 is true... flag2?: 0
flag2 is true


[Bug target/59343] miscompiled for loop in sh4 target (-Os)

2013-12-03 Thread gcc-bugzilla-f5d8 at theblacksun dot eu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59343

gcc-bugzilla-f5d8 at theblacksun dot eu changed:

   What|Removed |Added

  Known to work||4.7.3

--- Comment #6 from gcc-bugzilla-f5d8 at theblacksun dot eu ---
I tested your patch and it fixes the problem for me. Thanks for the quick
feedback.

Meanwhile I tested gcc 4.7.3. I cannot reproduce the miscompilation there.