From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jamie Lokier To: Marcel Cox Cc: Bernd Schmidt , gcc@gcc.gnu.org, jbuck@synopsys.COM, rms@gnu.org Subject: Re: type based aliasing again Date: Thu, 30 Sep 1999 18:02:00 -0000 Message-ID: <19990914174453.C12177@pcep-jamie.cern.ch> References: <37DE5830.EC1FAE36@cie.etat.lu> X-SW-Source: 1999-09n/msg00541.html Message-ID: <19990930180200.ud0sTFVypoHmuf3xBf8RZX2t9oxr0VbCvzi42hQOSbA@z> Marcel Cox wrote: > I know this does not proof it is safe. The fact however that a direct > typecast to int behaves differently from a union typecast shows that > the compiler handles this differently. Although it is not a proof, it should be possible to test the alias rules using a small program where only the type varies, but not the mode (size) of the types, and where we can be sure the optimiser will always reorder or remove memory accesses if type alias analysis permits it. E.g. T1 test (T1 val1, T1 * var1, T2 val2, T2 * var2) { *var1 = val1; *var2 = val2; return *var1; } I would confidently expect the optimiser to decide *var1 == val1 at the return point if T1 and T2 cannot alias. Unfortunately testing the union hack is more complicated than this, because the compiler has MEM_IN_STRUCT_P alias tests as well, which are affected by the union. This might give misleading results from Marcel's test. -- Jamie