ia64_get_dcr problem
Is this a GCC problem or a problem with the asm/ia64/processor.h inline functions??
I used the ia64_set_dcr & ia64_get_dcr functions in
a loop & got bad code. I had references to both ia64_get_dcr in ia64_set_dcr in the loop. The "get" was optimized out of the loop & did not see the result of the "set".
If I add "volatile" to the ia64_get_dcr asm statement, I can avoid the problem. But I am not sure whether this is the correct solution. (I hit a similar problem with ia64_get_irr0() earlier too).
I am using the "2.96-ia64-000717 snap 001117" compiler.
Source (stupid test but illustrates the problem):
void
dcrtest() {
long i, dcr;
for (i=0; i<10; i++) {
printk("0x%lx\n", ia64_get_dcr());
ia64_set_dcr(0x5555);
}
}Generated code:
<dcrtest.0> alloc r36=ar.pfs,0,5,2,0
<dcrtest.1> mov r34=cr.dcr <<< get
<dcrtest.2> mov r35=rp
<dcrtest+0x10.0> mov r33!845
<dcrtest+0x10.1> mov r32=9
<dcrtest+0x10.2> nop.i 0 <dcrtest+0x20.0> addl r37=-1091248,gp;;
<dcrtest+0x20.1> mov r38=r34
<dcrtest+0x20.2> nop.i 0
<dcrtest+0x30.0> ld8 r37=[r37]
<dcrtest+0x30.1> nop.i 0
<dcrtest+0x30.2> br.call.sptk.many rp=printk;;
<dcrtest+0x40.0> mov cr.dcr=r33;; <<< set
<dcrtest+0x40.1> srlz.d
<dcrtest+0x40.2> adds r32=-1,r32;;
<dcrtest+0x50.0> cmp.lt p7,p6=r32,r0
<dcrtest+0x50.1> nop.i 0
<dcrtest+0x50.2> (p6) br.cond.dptk.few dcrtest+0x20
<dcrtest+0x60.0> nop.m 0
<dcrtest+0x60.1> mov.i ar.pfs=r36
<dcrtest+0x60.2> mov rp=r35
<dcrtest+0x70.0> nop.m 0
<dcrtest+0x70.1> nop.i 0
<dcrtest+0x70.2> br.ret.sptk.many rp;;Signature · 3 lines
Thanks Jack Steiner (651-683-5302) (vnet 233-5302) [email protected]
It is a kernel problem. Your testcase can not work as intended without the volatile in the definition of ia64_get_dcr. It looks like the kernel doesn't actually use ia64_get_dcr, which is why the problem wasn't noticed before.
Jim
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jack Steiner
Jack> Is this a GCC problem or a problem with the Jack> asm/ia64/processor.h inline functions??
Jack> I used the ia64_set_dcr & ia64_get_dcr functions in a loop & Jack> got bad code. I had references to both ia64_get_dcr in Jack> ia64_set_dcr in the loop. The "get" was optimized out of the Jack> loop & did not see the result of the "set".
Jack> If I add "volatile" to the ia64_get_dcr asm statement, I can Jack> avoid the problem. But I am not sure whether this is the Jack> correct solution. (I hit a similar problem with Jack> ia64_get_irr0() earlier too).
Thanks for the report.
I fixed this now, along with a couple of other *get* macros in processor.h.
--david