This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
optimization/3311: GCC-SH: gcc loses result of AND operation due to force_to_mode bug
- To: gcc-gnats at gcc dot gnu dot org
- Subject: optimization/3311: GCC-SH: gcc loses result of AND operation due to force_to_mode bug
- From: tm2 at best dot com
- Date: 21 Jun 2001 08:06:29 -0000
- Reply-To: tm2 at best dot com
>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: