Generated code tight loops on HP-UX 10.20

Skip to first unread message

David Drysdale

Sep 2, 1997, 3:00:00 AM9/2/97

# /usr/local/bin/gcc -v
Reading specs from
gcc version 2.7.2

Failing File:
void f() { }
int c=1;
int main()
if (!c); /* note semi-colon */

Compile time arguments:
/usr/local/bin/gcc -o temp temp.c
(Also fails with /usr/local/bin/-ggdb -o temp temp.c)

No modifications to compiler source

Bug description: end up in a tight loop, calling f()

Disassembly of function main:
Dump of assembler code for function main:
0x2078 <main>: stw rp,-14(sr0,sp)
0x207c <main+4>: copy r3,r1
0x2080 <main+8>: copy sp,r3
0x2084 <main+12>: stwm r1,40(sr0,sp)
0x2088 <main+16>: bl 0x21b0 <__main>,rp
0x208c <main+20>: nop
0x2090 <main+24>: addil -800,dp
0x2094 <main+28>: ldo 7a0(r1),r19
0x2098 <main+32>: ldw 0(sr0,r19),r20
0x209c <main+36>: comibf,=,n 0,r20,0x20a0 <main+40>
0x20a0 <main+40>: bl 0x2060 <f>,rp
0x20a4 <main+44>: nop
0x20a8 <main+48>: ldw -14(sr0,r3),rp
0x20ac <main+52>: ldo 40(r3),sp
0x20b0 <main+56>: ldwm -40(sr0,sp),r3
0x20b4 <main+60>: bv,n r0(rp)
End of assembler dump.

Probable Cause: I'm not sure, but I think that instruction pipelining
the PA Risc chip means that the instruction after the conditional branch
at <main+36> is always executed, regardless of the conditional. This
means that the function f() gets called twice, and this then screws
up somehow . . . The distinguishing feature in the C code seems to be
an if() test followed by an empty block followed by a function call.


David Drysdale
Data Connection Ltd.

Reply all
Reply to author
0 new messages