public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/3311: GCC-SH: gcc loses result of AND operation due to force_to_mode bug
@ 2001-06-21  1:16 tm2
  0 siblings, 0 replies; 2+ messages in thread
From: tm2 @ 2001-06-21  1:16 UTC (permalink / raw)
  To: gcc-gnats

>Number:         3311
>Category:       optimization
>Synopsis:       GCC-SH: gcc loses result of AND operation due to force_to_mode bug
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 21 01:16:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Toshiyasu Morita
>Release:        3.0
>Organization:
>Environment:
host: i686-linux (Red Hat 7.0)
target: sh-elf
>Description:
When this code:

int b = 5;

void main(void)

{
        int a = 0;

        if (b) {
                func();
        }

        printf("%d\n", (a + 23) & 0xfffffffc);
}

is compiled with these options

-O1 -m4-single-only -ml -S 


the following code is created:

_main:
        mov.l   r14,@-r15
        sts.l   pr,@-r15
        mov.l   .L3,r1
        mov.l   @r1,r1
        tst     r1,r1
        bt.s    .L2
        mov     r15,r14
        mov.l   .L4,r0
        jsr     @r0
        nop
.L2:
        mov.l   .L5,r4
        mov.l   .L6,r0
        jsr     @r0
        mov     #23,r5
        mov     r14,r15
        lds.l   @r15+,pr
        rts
        mov.l   @r15+,r14
.L7:
        .align 2
.L3:
        .long   _b
.L4:
        .long   _func
.L5:
        .long   .LC0
.L6:
        .long   _printf


Basically, the code calls printf with the value "23" in r5, which is wrong.
.It should be calling printf with the value "20" in r5.

My analysis of the bug and patch are at:

http://gcc.gnu.org/ml/gcc-patches/2001-04/msg01267.html

>How-To-Repeat:

>Fix:
See message http://gcc.gnu.org/ml/gcc-patches/2001-04/msg01267.html
>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: optimization/3311: GCC-SH: gcc loses result of AND operation due to force_to_mode bug
@ 2002-03-28 15:35 law
  0 siblings, 0 replies; 2+ messages in thread
From: law @ 2002-03-28 15:35 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, tm2

Synopsis: GCC-SH: gcc loses result of AND operation due to force_to_mode bug

State-Changed-From-To: open->closed
State-Changed-By: law
State-Changed-When: Thu Mar 28 15:35:44 2002
State-Changed-Why:
    Fixed with change to combine.c::simplify_and_const_int.
    Testcase: execute/20020328-1.c

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3311


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

end of thread, other threads:[~2002-03-28 23:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-21  1:16 optimization/3311: GCC-SH: gcc loses result of AND operation due to force_to_mode bug tm2
2002-03-28 15:35 law

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