[PATCH] CodeGen: Give pointer parameters 'align' attributes

David Majnemer david.majnemer at gmail.com
Sun Sep 21 03:40:49 PDT 2014


================
Comment at: lib/Headers/avxintrin.h:784
@@ -783,3 +783,3 @@
 static __inline __m256d __attribute__((__always_inline__, __nodebug__))
-_mm256_loadu_pd(double const *__p)
+_mm256_loadu_pd(void const *__p)
 {
----------------
hfinkel wrote:
> majnemer wrote:
> > hfinkel wrote:
> > > Are the changes to this file related to the alignment change?
> > Yes. These intrinsics are intended to be used with pointers with any alignment.
> Ah, good point. But that's a problem. I'd need to make the same change to lib/Headers/altivec.h, but I don't think I can because it will interfere with the overloading. Even here, we lose type checking ability.
> 
> I think we may need to add some kind of attribute that can specify these pointers as unaligned (which, coincidentally, is my http://reviews.llvm.org/D4635 currently under review), or we need to make these take pointers to an underaligned type:
>   typedef double unaligned_double __attribute__((aligned(1)));
>   _mm256_loadu_pd(unaligned_double const *__p)
> Does that work? If not, maybe putting it in a transparent_union will work?
> 
> Finally, as this change points out, this has the possibility of breaking things. Should we add a flag, akin to -fno-strict-aliasing to disable this feature?
> 
I've changed the intrinsics to take underaligned pointers to complete types and I've also added -fno-strict-pointer-alignment to disable this optimization.

http://reviews.llvm.org/D5391






More information about the cfe-commits mailing list