This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/28011] New: [SH] g++ generates wrong code, if '-fno-exceptions' and '-O' options are specified


g++ generates wrong code, if '-fno-exceptions' and '-O' options are specified.
I did following tests. In the case of 1, wrong code was generated.

1. sh4-linux-g++ -S -O -fno-exceptions testcase.cc
2. sh4-linux-g++ -S -O2 -fno-exceptions testcase.cc

Source code is as follows but I will attach the testcase.
  PRBool dummy;
asm("POST:");
  return target->DispatchEvent(event, aDefaultAction ? aDefaultAction :
&dummy);

The result of case 1.
#APP
    POST:
#NO_APP
    mov.w   .L76,r0
    mov.w   .L79,r3
    add r14,r3
    mov.l   @(r0,r3),r4
    mov.l   @r4,r1
    mov.l   @(20,r1),r2
    mov.l   @r8,r5
    mov.l   @(44,r3),r1
    tst r1,r1
    bf  .L27
    mov.w   .L66,r1    # .L66:  .short  -188
    mov.w   .L79,r3    # .L79:  .short  188
    add r14,r3
    add r1,r3
    mov.l   r3,@(44,r3)  # this code is wrong because 44 is not right value
.L27:            # the value should be 232 - (188 - 188) but not 232 - 188
    mov.w   .L68,r0    # .L68:  .short  232
    mov.l   @(r0,r14),r6
    jsr @r2
    nop

The result of case 2. It seems that this case is right.
#APP
    POST:
#NO_APP
    mov.w   .L62,r3
    mov.l   @r13,r5
    add r14,r3
    mov.l   @(0,r3),r4
    mov.l   @(44,r3),r2
    mov.l   @r4,r1
    tst r2,r2
    mov.l   @(20,r1),r1
    bt  .L34
.L27:
    mov.w   .L58,r0
    mov.l   @(r0,r14),r6
    jsr @r1
    nop
    mov r0,r9
.L24:
    mov.l   .L63,r1
    jsr @r1
    mov r8,r4
...
.L34:
    mov.w   .L67,r2
    mov.w   .L68,r0
    add     r14,r2
    mov.l   r2,@(r0,r14)
    bra     .L27
    nop


-- 
           Summary: [SH] g++ generates wrong code, if '-fno-exceptions' and
                    '-O' options are specified
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: saito at densan dot co dot jp
 GCC build triplet: sh4-linux
  GCC host triplet: sh4-linux
GCC target triplet: sh4-linux


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]