This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: aliasing with char*
- From: Wouter Vermaelen <wouter dot vermaelen at coware dot be>
- To: eljay at adobe dot com
- Cc: gcc-help at gnu dot org
- Date: Mon, 19 Nov 2007 13:57:03 +0100
- Subject: Re: aliasing with char*
- References: <C366DF7E.26F8B%eljay@adobe.com>
- Reply-to: wouter dot vermaelen at coware dot be
John Love-Jensen wrote:
Hi Wouter,
What happens if you tell the compiler than the two cannot alias? I think
this is sufficient to do that...
-----------------------
/* -DT=short or -DT=char */
int count;
T f(T* restrict p) {
count += 2;
T t = *p;
count += 3;
return t;
}
-----------------------
gcc -std=iso9899:1999 -DT=char -O3 -S test.c -o test-char.s
gcc -std=iso9899:1999 -DT=short -O3 -S test.c -o test-short.s
vi -d test-char.s test-short.s
I already tried this, but unfortunately it doesn't work for me :(
> gcc -std=iso9899:1999 -DT=char -O3 -S test.c -o test-char.s
> cat test-char.s
...
movl count(%rip), %edx
leal 2(%rdx), %eax
addl $5, %edx
movl %eax, count(%rip)
movzbl (%rdi), %eax
movl %edx, count(%rip)
ret
...
> gcc --version
gcc (GCC) 4.3.0 20071119 (experimental)
...
> uname -a
Linux argon 2.6.22-3-amd64 #1 SMP Sun Nov 4 18:18:09 UTC 2007 x86_64 GNU/Linux
But thanks anyway.
Wouter