This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Restrict pointers
- From: "Jan Hoogerbrugge" <hoogerbrugge at hotmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 10 Mar 2004 10:19:26 +0100
- Subject: Restrict pointers
- Bcc:
Hi,
As far as I know, memory references via two pointers where one of them is a
restrict pointer and the other pointer is not restricted and is not derived
from the first one are independent. GCC sees it differently: both pointers
have to be restricted. I can demonstrate it by means of the following code:
int restrict_test0(int *p, int *q) /* no restrict pointers */
{
*p = 0;
return *q;
}
int restrict_test1a(int *restrict p, int *q) /* first pointer is restricted
*/
{
*p = 0;
return *q;
}
int restrict_test1b(int *p, int *restrict q) /* second pointer is restricted
*/
{
*p = 0;
return *q;
}
int restrict_test2(int *restrict p, int *restrict q) /* both pointers are
restricted */
{
*p = 0;
return *q;
}
The scheduler would like the schedule the long latency load of *p before the
store of *q. Dependences allow this only in the case of restrict_test2()
where two restrict pointers are involved. This is the resulting Alpha code
for 3.4.0 20040303:
$restrict_test0..ng:
restrict_test0:
.frame $30,0,$26,0
.prologue 0
stl $31,0($16)
ldl $0,0($17)
ret $31,($26),1
.end restrict_test0
.align 2
.align 4
.globl restrict_test1a
.ent restrict_test1a
$restrict_test1a..ng:
restrict_test1a:
.frame $30,0,$26,0
.prologue 0
stl $31,0($16)
ldl $0,0($17)
ret $31,($26),1
.end restrict_test1a
.align 2
.align 4
.globl restrict_test1b
.ent restrict_test1b
$restrict_test1b..ng:
restrict_test1b:
.frame $30,0,$26,0
.prologue 0
stl $31,0($16)
ldl $0,0($17)
ret $31,($26),1
.end restrict_test1b
.align 2
.align 4
.globl restrict_test2
.ent restrict_test2
$restrict_test2..ng:
restrict_test2:
.frame $30,0,$26,0
.prologue 0
ldl $0,0($17)
stl $31,0($16)
ret $31,($26),1
.end restrict_test2
.section .note.GNU-stack,"",@progbits
.ident "GCC: (GNU) 3.4.0 20040303 (prerelease)"
As you can see, only in the case of restrict_rest2, the load is scheduled
above the store. GCC should also do this in the case of restrict_test1a and
restrict_test1b.
I already filed this as a bug (14192) but the status remains unconfirmed for
several weeks. Could somebody tell whether this is ideed a performance bug?
Regards,
Jan
_________________________________________________________________
Talk with your online friends with MSN Messenger http://messenger.msn.nl/