* register declared variable for no optimization
@ 2003-01-30 23:11 Long Li
2003-01-31 2:20 ` Ralf Baechle
0 siblings, 1 reply; 2+ messages in thread
From: Long Li @ 2003-01-30 23:11 UTC (permalink / raw)
To: linux-mips
Hi,
I have a question on the GCC optimization. I am using
GCC3.0.4 MIPS crosscompiler on Redhat 7.1. In a
function I did the following:
init()
{
register unsigned int temp;
.
.
temp = devict.dev1.devtc
.
}
I compiled the code with optimization level 0 and
found something weird about the register variable
temp. This is shows in the disassembly file:
for temp = devict.dev1.devtc
lui $3, 0xb801
lw $3, 28($3)
This is right since the CPU loads the
devict.dev1.devtc value from memory to the register 3.
However, after the above instructions, I found:
nop
sw $3, 0($30)
lw $2, 0($30)
now the compiler asked the CPU to store the register
in the stack. However, I declared the variable as a
register, how come it still needs to go to the stack?
I compiled the same code with gcc-2.8.1, optimization
level 0, and did not find the same issue there.
Why the gcc-3.0.4 did the weird stuff? Do I have to
use at least level 1 to make the register declared
work for it?
Thanks a lot!
Long
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: register declared variable for no optimization
2003-01-30 23:11 register declared variable for no optimization Long Li
@ 2003-01-31 2:20 ` Ralf Baechle
0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2003-01-31 2:20 UTC (permalink / raw)
To: Long Li; +Cc: linux-mips
On Thu, Jan 30, 2003 at 03:11:19PM -0800, Long Li wrote:
> Why the gcc-3.0.4 did the weird stuff? Do I have to
> use at least level 1 to make the register declared
> work for it?
Most modern C compilers simply ignore the register specifier because in
practice it would result in worse code and as for code quality the
result of -O0 are not of interest anyway.
Linux code must be optmized at least -O1 or it probably won't build or
work properly.
Ralf
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-01-31 2:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-30 23:11 register declared variable for no optimization Long Li
2003-01-31 2:20 ` Ralf Baechle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.