From: Lokesh Janghel Date: Wed, 21 Nov 2018 20:09:56 +0000 (+0000) Subject: re PR target/85667 (ms_abi rules aren't followed when returning short structs with... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c339a8985df1288e569d550a1f22f50399e998e8;p=gcc.git re PR target/85667 (ms_abi rules aren't followed when returning short structs with float values) 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 82a1710e4e4..d789d9feeb0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-11-21 Lokesh Janghel + + 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 PR lto/87957 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index c18c60a1d19..41def54c5c0 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 29b0c83fc89..a25a24bf946 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +018-11-21 Lokesh Janghel + + 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 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 index 00000000000..d5508b7ace8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85667-1.c @@ -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 index 00000000000..c3c0ba3a4b0 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85667-2.c @@ -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 index 00000000000..73e83bcf9be --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85667-3.c @@ -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 index 00000000000..a49f06b0861 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85667-4.c @@ -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; +}