OSDN Git Service

Backport from mainline
authoruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Feb 2014 16:46:06 +0000 (16:46 +0000)
committeruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Feb 2014 16:46:06 +0000 (16:46 +0000)
2014-02-02  Uros Bizjak  <ubizjak@gmail.com>

PR target/60017
* config/i386/i386.c (classify_argument): Fix handling of bit_offset
when calculating size of integer atomic types.

testsuite/ChangeLog

Backport from mainline
2014-02-02  Uros Bizjak  <ubizjak@gmail.com>

PR target/60017
* gcc.c-torture/execute/pr60017.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@207476 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr60017.c [new file with mode: 0644]

index 77d5124..446ca4a 100644 (file)
@@ -1,3 +1,12 @@
+2014-02-04  Uros Bizjak  <ubizjak@gmail.com>
+
+       Backport from mainline
+       2014-02-02  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/60017
+       * config/i386/i386.c (classify_argument): Fix handling of bit_offset
+       when calculating size of integer atomic types.
+
 2014-02-02  Uros Bizjak  <ubizjak@gmail.com>
 
        Backport from mainline
 2014-02-02  Uros Bizjak  <ubizjak@gmail.com>
 
        Backport from mainline
index 447f6f2..25ec814 100644 (file)
@@ -6078,25 +6078,28 @@ classify_argument (enum machine_mode mode, const_tree type,
     case CHImode:
     case CQImode:
       {
     case CHImode:
     case CQImode:
       {
-       int size = (bit_offset % 64)+ (int) GET_MODE_BITSIZE (mode);
+       int size = bit_offset + (int) GET_MODE_BITSIZE (mode);
 
 
-       if (size <= 32)
+       /* Analyze last 128 bits only.  */
+       size = (size - 1) & 0x7f;
+
+       if (size < 32)
          {
            classes[0] = X86_64_INTEGERSI_CLASS;
            return 1;
          }
          {
            classes[0] = X86_64_INTEGERSI_CLASS;
            return 1;
          }
-       else if (size <= 64)
+       else if (size < 64)
          {
            classes[0] = X86_64_INTEGER_CLASS;
            return 1;
          }
          {
            classes[0] = X86_64_INTEGER_CLASS;
            return 1;
          }
-       else if (size <= 64+32)
+       else if (size < 64+32)
          {
            classes[0] = X86_64_INTEGER_CLASS;
            classes[1] = X86_64_INTEGERSI_CLASS;
            return 2;
          }
          {
            classes[0] = X86_64_INTEGER_CLASS;
            classes[1] = X86_64_INTEGERSI_CLASS;
            return 2;
          }
-       else if (size <= 64+64)
+       else if (size < 64+64)
          {
            classes[0] = classes[1] = X86_64_INTEGER_CLASS;
            return 2;
          {
            classes[0] = classes[1] = X86_64_INTEGER_CLASS;
            return 2;
index 8ede531..ac13876 100644 (file)
@@ -1,3 +1,11 @@
+2014-02-04  Uros Bizjak  <ubizjak@gmail.com>
+
+       Backport from mainline
+       2014-02-02  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/60017
+       * gcc.c-torture/execute/pr60017.c: New test.
+
 2014-02-03  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/59941
 2014-02-03  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/59941
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr60017.c b/gcc/testsuite/gcc.c-torture/execute/pr60017.c
new file mode 100644 (file)
index 0000000..d72c12c
--- /dev/null
@@ -0,0 +1,33 @@
+/* PR target/60017 */
+
+extern void abort (void);
+
+struct S0
+{
+  short m0;
+  short m1;
+};
+
+struct S1
+{
+  unsigned m0:1;
+  char m1[2][2];
+  struct S0 m2[2];
+};
+
+struct S1 x = { 1, {{2, 3}, {4, 5}}, {{6, 7}, {8, 9}} };
+
+struct S1 func (void)
+{
+  return x;
+}
+
+int main (void)
+{
+  struct S1 ret = func ();
+
+  if (ret.m2[1].m1 != 9)
+    abort ();
+
+  return 0;
+}