|
Message-Id: <C579A7F1-C1D0-4B68-9E1D-30D4EC7AF33E@gmail.com>
Date: Tue, 15 Sep 2015 23:30:25 +0800
From: Lei Zhang <zhanglei.april@...il.com>
To: john-dev@...ts.openwall.com
Subject: Strict aliasing in SIMD code
Hey guys,
I was thinking about polishing the pseudo-intrinsics for NEON and AltiVec when this topic came to me. We've discussed it before, but I don't think we've really fixed this issue in JtR so far. I found an interesting SO link that's related to our problem and might be worth reading: http://stackoverflow.com/questions/24787268/how-to-implement-mm-storeu-epi64-without-aliasing-problems <http://stackoverflow.com/questions/24787268/how-to-implement-mm-storeu-epi64-without-aliasing-problems>
Hinted by the above link, I checked the headers of gcc (5.2.0), and it do use the __may_alias__ attribute when declaring vector types:
(from avx512fintrin.h)
/* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components. */
typedef float __m512 __attribute__ ((__vector_size__ (64), __may_alias__));
typedef long long __m512i __attribute__ ((__vector_size__ (64), __may_alias__));
typedef double __m512d __attribute__ ((__vector_size__ (64), __may_alias__));
clang's header also used this attribute in its intrinsics-related headers, but in a different way, like this one (also from avx512fintrin.h):
static __inline __m512d __attribute__((__always_inline__, __nodebug__))
_mm512_loadu_pd(double const *__p)
{
struct __loadu_pd {
__m512d __v;
} __attribute__((packed, may_alias));
return ((struct __loadu_pd*)__p)->__v;
}
icc doesn't use this attribute, but I don't it's a problem for icc, since it's the most authoritative adopter of x86 intrinsics. I haven't checked MSVC++ yet.
I think maybe we shouldn't worry about strict-aliasing anymore when using SIMD intrinsics, as (most) compilers are already taking care of this issue for us.
Lei
Content of type "text/html" skipped
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.