re PR target/85667 (ms_abi rules aren't followed when returning short structs with...
authorLokesh Janghel <lokeshjanghel91@gmail.com>
Wed, 21 Nov 2018 20:09:56 +0000 (20:09 +0000)
committerUros Bizjak <uros@gcc.gnu.org>
Wed, 21 Nov 2018 20:09:56 +0000 (21:09 +0100)
PR target/85667
* config/i386/i386.c (function_value_ms_64): Return AX_REG instead
of FIRST_SSE_REG for 4 or 8 byte modes.

testsuite/ChangeLog:

PR target/85667
* gcc.target/pr85667-1.c: New testcase.
* gcc.target/pr85667-2.c: New testcase.
* gcc.target/pr85667-3.c: New testcase.
* gcc.target/pr85667-4.c: New testcase.

From-SVN: r266355

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr85667-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr85667-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr85667-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr85667-4.c [new file with mode: 0644]

index 82a1710e4e467cf6bd4facf9801318bd7d591d70..d789d9feeb04eb90fc5152cac79db6a0927c6f6b 100644 (file)
@@ -1,3 +1,9 @@
+2018-11-21  Lokesh Janghel  <lokeshjanghel91@gmail.com>
+
+       PR target/85667
+       * config/i386/i386.c (function_value_ms_64): Return AX_REG instead
+       of FIRST_SSE_REG for 4 or 8 byte modes.
+
 2018-11-21  Jan Hubicka  <jh@suse.cz>
 
        PR lto/87957
index c18c60a1d191b98c3342886d63bfbe626ffbf8d8..41def54c5c035b20434887ad3db503e84edbf037 100644 (file)
@@ -9005,11 +9005,6 @@ function_value_ms_64 (machine_mode orig_mode, machine_mode mode,
              && !COMPLEX_MODE_P (mode))
            regno = FIRST_SSE_REG;
          break;
-       case 8:
-       case 4:
-         if (mode == SFmode || mode == DFmode)
-           regno = FIRST_SSE_REG;
-         break;
        default:
          break;
         }
index 29b0c83fc8961fd17a85d4780b0fdb59c32b6649..a25a24bf946c4f2cbe6f41af89d018f469b4e950 100644 (file)
@@ -1,3 +1,11 @@
+018-11-21  Lokesh Janghel  <lokeshjanghel91@gmail.com>
+
+       PR target/85667
+       * gcc.target/pr85667-1.c: New testcase.
+       * gcc.target/pr85667-2.c: New testcase.
+       * gcc.target/pr85667-3.c: New testcase.
+       * gcc.target/pr85667-4.c: New testcase.
+
 2018-11-21  Jan Hubicka  <hubicka@ucw.cz>
 
        PR lto/87957
diff --git a/gcc/testsuite/gcc.target/i386/pr85667-1.c b/gcc/testsuite/gcc.target/i386/pr85667-1.c
new file mode 100644 (file)
index 0000000..d5508b7
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do run { target lp64 } } */
+/* { dg-options "-O2" } */
+
+void abort (void);
+
+typedef struct
+{
+  float x;
+} Float;
+
+Float __attribute__((ms_abi)) fn1 ()
+{
+  Float v;
+  v.x = 3.145;
+  return v;
+}
+
+Float fn2 ()
+{
+  Float v;
+  v.x = 3.145;
+  return v;
+}
+
+int main ()
+{
+  Float a, b;
+  a = fn1 ();
+  b = fn2 ();
+  if (a.x == 3.145f && b.x == 3.145f)
+    return 0; 
+  abort ();   
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr85667-2.c b/gcc/testsuite/gcc.target/i386/pr85667-2.c
new file mode 100644 (file)
index 0000000..c3c0ba3
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-times "movl\[^\n\r]*, %eax|mov\[ \t]*eax," 1 } } */
+
+typedef struct
+{
+  float x;
+} Float;
+
+Float __attribute__((ms_abi)) fn1 ()
+{
+  Float v;
+  v.x = 3.145;
+  return v;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr85667-3.c b/gcc/testsuite/gcc.target/i386/pr85667-3.c
new file mode 100644 (file)
index 0000000..73e83bc
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do run { target lp64 } } */
+/* { dg-options "-O2" } */
+
+void abort (void);
+
+typedef struct
+{
+  double x;
+} Double;
+
+Double __attribute__((ms_abi)) fn1 ()
+{
+  Double v;
+  v.x = 3.145;
+  return v;
+}
+
+Double fn2 ()
+{
+  Double v;
+  v.x = 3.145;
+  return v;
+}
+
+int main ()
+{
+  Double a, b;
+  a = fn1 ();
+  b = fn2 ();
+  if (a.x == 3.145 && b.x == 3.145)
+    return 0; 
+  abort ();   
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr85667-4.c b/gcc/testsuite/gcc.target/i386/pr85667-4.c
new file mode 100644 (file)
index 0000000..a49f06b
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-times "movq\[^\n\r]*, %rax|mov\[ \t]*rax," 1 } } */
+
+typedef struct
+{
+  double x;
+} Double;
+
+Double  __attribute__((ms_abi)) fn1 ()
+{
+  Double v;
+  v.x = 3.145;
+  return v;
+}