public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* target/8972: the c code ' x << i' causes infinite loop when i = 0
@ 2002-12-17 1:16 or.poran
0 siblings, 0 replies; only message in thread
From: or.poran @ 2002-12-17 1:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 8972
>Category: target
>Synopsis: the c code ' x << i' causes infinite loop when i = 0
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Tue Dec 17 01:16:03 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Or Poran
>Release: Configured with: ./configure --prefix=/afs/iil/home/o/oporan/fw/gcc/gcc-3.2/../install/ --target=arc-7-elf
>Organization:
>Environment:
Linux
gcc as a cross compiler for arc.
>Description:
the folloing code:
# 1 "a.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "a.c"
int f(int x, int i)
{
return x << i;
}
produce the following asm code:
.cpu base
.section .text
.align 4
.global _f
.type _f,@function
_f:
; BEGIN PROLOGUE ; vars= 0, regs= 0, args= 0, extra= 0
st fp,[sp]
mov fp,sp
; END PROLOGUE
mov lp_count,r1
mov r2,%st(1f) ; (single insn loop start) >> 2
sr r2,[lp_start]
add r2,r2,1
sr r2,[lp_end]
nop
nop
1: ; single insn loop
asl r0,r0
; EPILOGUE
j.d blink
ld.a fp,[sp,0]
.Lfe1:
.size _f,.Lfe1-_f
.ident "GCC: (GNU) 3.2"
if i is set to 0, the loop counter will wrap around to 0xfffffff thus crating very long loop.
>How-To-Repeat:
>Fix:
a diffrent compiler produce the following asm code
.file "a.c"
.option %reg
.ident "hc4.5a -arc7 -O1 a.c"
.seg ".text",text
.L00TEXT:
;-------------| f |-------------------
.global f
f:
asr.f %lp_count, %r1
lsl.cs %r0, %r0
lpne .LP01.4
lsl %r0, %r0
lsl %r0, %r0
.LP01.4:
j [%blink]
.type f, @function
.size f, . - f
.end
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-12-17 9:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-17 1:16 target/8972: the c code ' x << i' causes infinite loop when i = 0 or.poran
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).