From patchwork Sun Nov 27 17:29:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allan Sandfeld Jensen X-Patchwork-Id: 84340 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp1222282obn; Sun, 27 Nov 2016 09:29:52 -0800 (PST) X-Received: by 10.99.178.89 with SMTP id t25mr32032525pgo.131.1480267792014; Sun, 27 Nov 2016 09:29:52 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id k4si23587848plb.70.2016.11.27.09.29.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Nov 2016 09:29:52 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-442731-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-442731-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-442731-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:cc:references:in-reply-to:mime-version :content-type:message-id; q=dns; s=default; b=ieWO/+aM5VlyZNBMZb ynAHej4mvaE4r6EqA9K9bcFIo4mQNuf3WT5MA3jqpm3hRGdj/6fdwqeFNWNgzefB FIev2yISMMB8zmU4HYnJsotjN3obTkKDDhY82GSkQ5rD4mvh/BDbVgQQ60SLJVeh Lq6rbYGloo5VWzZ9Rz6Bm5Z0c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:cc:references:in-reply-to:mime-version :content-type:message-id; s=default; bh=RWc6I8g6wPQaoaMO4o83OP2k qF0=; b=OKeF4MyuD9d/ir9MefPftKN/gtWcsweQZoFyBY27FeBwyHMiU7/KbLPq Mz9DqAqhJOJTq0uVVWryucBGLHXt1Kojvhi+jCl6urQv5CaV5oigtmz87zQ1GwO0 hgCYWBLVvNuTo/hoSlo8JECtpju+aZvvWCVaBqarGcg1kUlKTng= 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@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 18:29:22 +0100 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 Message-Id: <201611271829.22468.linux@carewolf.com> X-IsSubscribed: yes 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. 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)));