Bug 33705 - restrict doesn't improve char * aliasing
Summary: restrict doesn't improve char * aliasing
Status: RESOLVED DUPLICATE of bug 14187
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: alias, missed-optimization
Depends on:
Blocks:
 
Reported: 2007-10-09 03:14 UTC by astrange+gcc@gmail.com
Modified: 2008-10-01 14:40 UTC (History)
13 users (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
source (391 bytes, text/plain)
2007-10-09 03:14 UTC, astrange+gcc@gmail.com
Details
resulting x86-64 asm (554 bytes, text/plain)
2007-10-09 03:15 UTC, astrange+gcc@gmail.com
Details
source with __restrict (no change) (402 bytes, text/plain)
2008-04-20 23:48 UTC, astrange+gcc@gmail.com
Details

Note You need to log in before you can comment on or make changes to this bug.
Description astrange+gcc@gmail.com 2007-10-09 03:14:16 UTC
> /usr/local/gcc43/bin/gcc -O3 -fno-pic -fomit-frame-pointer -m64 -S gcc-struct-stores.i -v
Using built-in specs.
Target: i386-apple-darwin8.10.1
Configured with: ../gcc/configure --prefix=/usr/local/gcc43 --with-arch=nocona --with-tune=nocona --with-gmp=/sw --with-system-zlib --enable-languages=c,c++,objc,obj-c++ --disable-bootstrap
Thread model: posix
gcc version 4.3.0 20071008 (experimental) (GCC) 

GCC updates c->low and c->range in the middle of the function:
	movl	%r8d, (%rdi)
	movl	%edx, 4(%rdi)

but they're overwritten at the end:
	movl	%edx, 4(%rdi)
	sall	%cl, (%rdi)

I don't know if there are aliasing issues, but marking it __restrict doesn't affect it.
Comment 1 astrange+gcc@gmail.com 2007-10-09 03:14:49 UTC
Created attachment 14328 [details]
source
Comment 2 astrange+gcc@gmail.com 2007-10-09 03:15:28 UTC
Created attachment 14329 [details]
resulting x86-64 asm

/usr/local/gcc43/bin/gcc -O3 -fno-pic -fomit-frame-pointer -m64 -S gcc-struct-stores.i
Comment 3 Andrew Pinski 2007-10-09 10:30:43 UTC
> I don't know if there are aliasing issues, but marking it __restrict doesn't affect it.

It is as changing state to be uint32_t and add restrict to both arguments makes it work correctly.
The issue here is that we say character types alias everything even stuff which have restrict on them.
Comment 4 astrange+gcc@gmail.com 2008-04-20 23:48:27 UTC
Created attachment 15502 [details]
source with __restrict (no change)
Comment 5 Richard Biener 2008-10-01 14:40:08 UTC
This is because restrict is implemented as regular alias-sets.

*** This bug has been marked as a duplicate of 14187 ***