On 10/20/18 10:53 AM, Segher Boessenkool wrote: > Hi! > > On Fri, Oct 19, 2018 at 04:27:27PM -0500, Bill Schmidt wrote: >> The x86 intrinsic compatibility headers contain a couple of instances of >> undefined behavior where a cast to an aligned type is used when that >> alignment is not guaranteed by the expression to be cast from. This >> patch fixes that problem by replacing the aligned types with unaligned >> versions of the same type. > How did you find these? What I'm after is, did you find all instances?
Jinsong found these by using the test cases for these header files when incorporating the headers into Clang. I will ask him whether he scanned for additional similar cases. > >> --- gcc/config/rs6000/xmmintrin.h (revision 265318) >> +++ gcc/config/rs6000/xmmintrin.h (working copy) >> @@ -85,6 +85,9 @@ >> vector types, and their scalar components. */ >> typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__)); >> >> +/* Unaligned version of the same type. */ >> +typedef float __m128_u __attribute__ ((__vector_size__ (16), >> __may_alias__)); > This is identical to __m128. Do you want aligned(1) as well? Argh, yes. I failed to copy this correctly from Jinsong. I will re-test before applying. Thanks! Bill > > Okay for trunk if you want that; if not, this needs explanation (a code > comment or similar). > > Thanks! > > > Segher >