From: Allan Sandfeld Jensen <linux@carewolf.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Marc Glisse <marc.glisse@inria.fr>
Subject: [Patch][i386] PR 70118: Fix ubsan warning on SSE2 loadl_epi64 and storel_epi64
Date: Sat, 26 Nov 2016 22:11:00 -0000 [thread overview]
Message-ID: <201611262310.59348.linux@carewolf.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 189 bytes --]
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
[-- Attachment #2: unaligned-sse_epi64.diff --]
[-- Type: text/x-patch, Size: 1652 bytes --]
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)));
next reply other threads:[~2016-11-26 22:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-26 22:11 Allan Sandfeld Jensen [this message]
2016-11-26 23:15 ` Marc Glisse
2016-11-27 17:29 ` Allan Sandfeld Jensen
2016-12-05 21:36 ` Allan Sandfeld Jensen
2016-12-06 8:31 Uros Bizjak
2016-12-09 22:49 ` Allan Sandfeld Jensen
2016-12-11 16:28 ` Uros Bizjak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201611262310.59348.linux@carewolf.com \
--to=linux@carewolf.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=marc.glisse@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).