From patchwork Sat Nov 26 22:10:59 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: 84317 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp590418qgi; Sat, 26 Nov 2016 14:11:29 -0800 (PST) X-Received: by 10.98.194.130 with SMTP id w2mr14267491pfk.143.1480198289536; Sat, 26 Nov 2016 14:11:29 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b10si44293765pfd.39.2016.11.26.14.11.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Nov 2016 14:11:29 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-442713-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-442713-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-442713-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:mime-version:content-type:message-id; q=dns; s=default; b=wlUMXvT6kd9F8hh4nOAFbu/y4RrQ2grptQ2Afbxn9mtOhsO5FT 8rcaO1YH3fHwsCzEdIWl9IN6vTuPTlMbrZg2jJfX2L1mnAshwvd1k0xipEBdQ9g3 M91lqiq9F0KSHAInQpXx19tANdC7HzcGbagFRCB34IX/Z25UhhUITSxRw= 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:mime-version:content-type:message-id; s= default; bh=FEfCzGGVjJ0OHIHk8HV8Fr5J5Ls=; b=egqqwt60abt+cI30OWTF 2HPlm2ui5nZaLUmB8QL2eiHbAyyB7UYjovW0HdZ2jrIGIekz+nEpia9j3ynz0eXm pG0mxh6+Jv3pewn/6Ot8IyebxwGRNUstpClTHLzTKAenitnjXNmkf1sb8tU6iA54 fTT4G+kWCIPmeBwUpSHhNR8= Received: (qmail 84382 invoked by alias); 26 Nov 2016 22:11:15 -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 84361 invoked by uid 89); 26 Nov 2016 22:11:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=H*c:HounHHry, H*c:Multipart X-HELO: mailrelay9.public.one.com Received: from mailrelay9.public.one.com (HELO mailrelay9.public.one.com) (195.47.247.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 26 Nov 2016 22:11:03 +0000 X-HalOne-Cookie: d61cde1630ade36e1155d08d6378272d10aac3f5 X-HalOne-ID: 36200566-b425-11e6-af58-b82a72d03b9b Received: from princessluna.localnet (unknown [93.230.134.50]) by smtpfilter2.public.one.com (Halon) with ESMTPSA id 36200566-b425-11e6-af58-b82a72d03b9b; Sat, 26 Nov 2016 22:11:00 +0000 (UTC) From: Allan Sandfeld Jensen To: GCC Patches Subject: [Patch][i386] PR 70118: Fix ubsan warning on SSE2 loadl_epi64 and storel_epi64 Date: Sat, 26 Nov 2016 23:10:59 +0100 User-Agent: KMail/1.13.7 (Linux/4.8.0-7.1-liquorix-amd64; KDE/4.14.26; x86_64; ; ) Cc: Marc Glisse MIME-Version: 1.0 Message-Id: <201611262310.59348.linux@carewolf.com> X-IsSubscribed: yes 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. `Allan Index: gcc/config/i386/emmintrin.h =================================================================== --- gcc/config/i386/emmintrin.h (revision 242753) +++ 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 242753) +++ 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)));