public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [PATCH, i386]: fix PR 66922, wrong code for bit-field struct
Date: Sat, 18 Jul 2015 15:38:00 -0000	[thread overview]
Message-ID: <CAFULd4ay_NverLhSrTU39jWHP+7O=aRwQcwXv2P-gn9k4oKC8A@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 587 bytes --]

We have to reject misaligned insertions and extractions from
ix86_expand_pextr and  ix86_expand_pinsr.

2015-07-18  Uros Bizjak  <ubizjak@gmail.com>

    PR target/66922
    * config/i386/i386.c (ix86_expand_pextr): Reject extractions
    from misaligned positions.
    (ix86_expand_pinsr): Reject insertions to misaligned positions.

testsuite/ChangeLog:

2015-07-18  Uros Bizjak  <ubizjak@gmail.com>

    PR target/66922
    * gcc.target/i386/pr66922.c: New test.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN and release branches.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 1230 bytes --]

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 225979)
+++ config/i386/i386.c	(working copy)
@@ -50591,6 +50591,10 @@ ix86_expand_pextr (rtx *operands)
 	    return false;
 	  }
 
+	/* Reject extractions from misaligned positions.  */
+	if (pos & (size-1))
+	  return false;
+
 	if (GET_MODE (dst) == dstmode)
 	  d = dst;
 	else
@@ -50687,6 +50691,10 @@ ix86_expand_pinsr (rtx *operands)
 	    return false;
 	  }
 
+	/* Reject insertions to misaligned positions.  */
+	if (pos & (size-1))
+	  return false;
+
 	if (GET_CODE (src) == SUBREG)
 	  {
 	    unsigned int srcpos = SUBREG_BYTE (src);
Index: testsuite/gcc.target/i386/pr66922.c
===================================================================
--- testsuite/gcc.target/i386/pr66922.c	(revision 0)
+++ testsuite/gcc.target/i386/pr66922.c	(working copy)
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-options "-O1 -msse2" } */
+/* { dg-require-effective-target sse2 } */
+
+#include "sse2-check.h"
+
+struct S 
+{
+  int:31;
+  int:2;
+  int f0:16;
+  int f1;
+  int f2;
+};
+
+static void 
+sse2_test (void)
+{
+  struct S a = { 1, 0, 0 };
+
+  if (a.f0 != 1)
+    __builtin_abort(); 
+}

                 reply	other threads:[~2015-07-18  9:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CAFULd4ay_NverLhSrTU39jWHP+7O=aRwQcwXv2P-gn9k4oKC8A@mail.gmail.com' \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).