This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ipa/65270] [5 regression] ICF needs to match TYPE attributes on memory accesses
- From: "hubicka at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 05 Mar 2015 00:42:51 +0000
- Subject: [Bug ipa/65270] [5 regression] ICF needs to match TYPE attributes on memory accesses
- Auto-submitted: auto-generated
- References: <bug-65270-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65270
--- Comment #19 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
I tried to construct a testcase for __restrict__ case:
int var;
const int *varptr=&var;
const int *__restrict__ varptr2=&var;
int *__restrict__ varptr3 = &var;
int *__restrict__ varptr4 = &var;
int *
return_valptr(int i)
{
return varptr[i];
}
int * __restrict__
return_valptr2(int i)
{
return varptr2[i];
}
int
testrestrict ()
{
int *ptr = return_valptr (0);
*ptr = 0;
*varptr3 = 1;
return *ptr;
}
int
testrestrict2 ()
{
int *ptr = return_valptr2 (0);
*ptr = 0;
*varptr3 = 1;
return *ptr;
}
int
testrestrict4 ()
{
*varptr4 = 0;
*varptr3 = 1;
return *varptr4;
}
Here I would like restrict2 to return uncondtional 0, because ptr is taken from
a restrict pointer in a global var. For whatever reason this optimization is
not happening (it happens in testrestrict4). So perhaps we are safe to
completely ignore restircts on vars, because we never get the flag in through
folding.