From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33496 invoked by alias); 27 Nov 2016 17:29:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 33482 invoked by uid 89); 27 Nov 2016 17:29:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.6 required=5.0 tests=BAYES_50,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=H*c:HounHHry, H*c:Multipart, __v4hi, sk:__alway X-HELO: mailrelay11.public.one.com Received: from mailrelay11.public.one.com (HELO mailrelay11.public.one.com) (195.47.247.189) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 27 Nov 2016 17:29:27 +0000 X-HalOne-Cookie: 6b115855bf76fd43dd2d22549d29af51b087bfaf X-HalOne-ID: 0951abd6-b4c7-11e6-b294-b82a72d06996 Received: from princessluna.localnet (unknown [93.230.135.243]) by smtpfilter3.public.one.com (Halon) with ESMTPSA id 0951abd6-b4c7-11e6-b294-b82a72d06996; Sun, 27 Nov 2016 17:29:23 +0000 (UTC) From: Allan Sandfeld Jensen To: gcc-patches@gcc.gnu.org Subject: Re: [Patch][i386] PR 70118: Fix ubsan warning on SSE2 loadl_epi64 and storel_epi64 Date: Sun, 27 Nov 2016 17:29:00 -0000 User-Agent: KMail/1.13.7 (Linux/4.8.0-7.1-liquorix-amd64; KDE/4.14.26; x86_64; ; ) Cc: Marc Glisse , Uros Bizjak References: <201611262310.59348.linux@carewolf.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_yfxOYaDG90c/uSn" Message-Id: <201611271829.22468.linux@carewolf.com> X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg02717.txt.bz2 --Boundary-00=_yfxOYaDG90c/uSn Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-length: 855 On Sunday 27 November 2016, Marc Glisse wrote: > On Sat, 26 Nov 2016, Allan Sandfeld Jensen wrote: > > Use the recently introduced unaligned variant of __m128i and add a > > similar __m64 and use those to make it clear these two intrinsics > > require neither 128- bit nor 64-bit alignment. > > Thanks for doing this. You'll want Uros or Kirill to review your patch. > There are probably several more places that could do with an unaligned > fix, but we don't have to find them all at once. > First I found it strange to use __m64, but then it actually seems like a > good call to use a type that is not just aligned(1) but also may_alias. > > + *(__m64_u *)__P = __m64(((__v2di)__B)[0]); > > gcc complains about this syntax for me, it wants parentheses around > __m64... Did it pass the testsuite for you? Fixed, it now matches the move just below. --Boundary-00=_yfxOYaDG90c/uSn Content-Type: text/x-patch; charset="UTF-8"; name="unaligned_sse2_epi64.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="unaligned_sse2_epi64.diff" Content-length: 1653 Index: gcc/config/i386/emmintrin.h =================================================================== --- gcc/config/i386/emmintrin.h (revision 242892) +++ gcc/config/i386/emmintrin.h (working copy) @@ -703,9 +703,9 @@ } extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) -_mm_loadl_epi64 (__m128i const *__P) +_mm_loadl_epi64 (__m128i_u const *__P) { - return _mm_set_epi64 ((__m64)0LL, *(__m64 *)__P); + return _mm_set_epi64 ((__m64)0LL, *(__m64_u *)__P); } extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) @@ -721,9 +721,9 @@ } extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) -_mm_storel_epi64 (__m128i *__P, __m128i __B) +_mm_storel_epi64 (__m128i_u *__P, __m128i __B) { - *(long long *)__P = ((__v2di)__B)[0]; + *(__m64_u *)__P = (__m64) ((__v2di)__B)[0]; } extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) Index: gcc/config/i386/mmintrin.h =================================================================== --- gcc/config/i386/mmintrin.h (revision 242892) +++ gcc/config/i386/mmintrin.h (working copy) @@ -37,6 +37,9 @@ vector types, and their scalar components. */ typedef int __m64 __attribute__ ((__vector_size__ (8), __may_alias__)); +/* Unaligned version of the same type */ +typedef int __m64_u __attribute__ ((__vector_size__ (8), __may_alias__, __aligned__ (1))); + /* Internal data types for implementing the intrinsics. */ typedef int __v2si __attribute__ ((__vector_size__ (8))); typedef short __v4hi __attribute__ ((__vector_size__ (8))); --Boundary-00=_yfxOYaDG90c/uSn--