This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
PowerPC reusing CTR register for nested loops
- To: egcs-bugs at cygnus dot com
- Subject: PowerPC reusing CTR register for nested loops
- From: David Edelsohn <dje at watson dot ibm dot com>
- Date: Fri, 11 Sep 1998 00:56:40 -0400
The PowerPC target has not been using the CTR register for loops.
This is caused by a special optimization that Haifa added which never is
enabled for any optimization level. Enabling it causes a bootstrap
failure which I have been trying to track down.
What appears to be happening is the CTR register is used for two
nested loops making the count for the outer loop invalid.
loop.c:scan_loop is called for each loop from the inside loop
outward. When the CTR register optimization finds a loop that can utilize
the CTR regsiter, it walks up loop_outer_loop[] vector marking the outer
loops with a CTR busy flag.
Looking at the loop phase output, the optimization is finding loop
10 can use the register, then loop 9 can use the register. It clearly is
searching the loops from highest number to lowest -- inner to outer. But
the assembly shows two nested loops using the CTR register:
mtctr 20 <--- load CTR
L..531:
cmpw 0,5,27
bc 4,1,L..475
add 10,3,22
add 11,4,22
mtctr 6 <--- load CTR
L..530:
lwz 8,0(10)
lwz 7,0(11)
lwz 9,12(8)
lwz 0,12(7)
cmpw 0,9,0
bc 4,0,L..479
stw 8,0(11)
stw 7,0(10)
L..479:
addi 10,10,-4
addi 11,11,-4
bdnz L..530 <--- decrement and branch
L..475:
addi 6,6,-1
addi 27,27,1
bdnz L..531 <--- decrement and branch
Does anyone have any idea how this could be getting confused? I slowly am
digging into what the compiler thinks it is doing as time permits, but I
am curious if anybody knows of changes to loop.c that could be affecting
this.
Thanks, David