From patchwork Wed Feb 5 17:58:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1233965 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518972-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=wx4v3KQd; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=UCse0hDA; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48CTpw3NdFz9sRh for ; Thu, 6 Feb 2020 04:59:36 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=yaaW0h8FbS383t6/knoKmsWibHlsXjeUGYVtsbfwcUhy0z 5ar+meUxfkfhm5kuRlpQ7tJRRWDkJ7sHONfpXiFpp1KNfcYBAAW83i77WXyRcapT 7k9XM88od0qysit8h1uaCveVefaVuDb/jMOkxeDXTEwwOGEWnrGnYHTrO3dFM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=XpklyU5f+/DWPfDtjCYNXHaJWwk=; b=wx4v3KQdxgywduXm8smf Tr0wbtmJoK0pKuJXP4SWzz5nlWf9lyP/Lhz32ogLs7h1JLkyiKAOmpvL2aE8m1vp vTPE/lBkqoWUGB3MZdsqgAfJwFq2xlgJfXd2PMIvlu3jENFW10/z1aXy8i3BNMnc Endw+kJz7JnGye5S8lFmfDY= Received: (qmail 7076 invoked by alias); 5 Feb 2020 17:59:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 7027 invoked by uid 89); 5 Feb 2020 17:59:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=msabi, 4.2 X-HELO: mail-oi1-f194.google.com Received: from mail-oi1-f194.google.com (HELO mail-oi1-f194.google.com) (209.85.167.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Feb 2020 17:59:24 +0000 Received: by mail-oi1-f194.google.com with SMTP id v19so1605426oic.12 for ; Wed, 05 Feb 2020 09:59:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=CrnmORsGXZ2d8QDqgBEgQI6tfJ6NeOTBiBscC1WhduM=; b=UCse0hDAr4JhNT6AzHvKe72gupcHifWGAuHXqE90kHsqlim2jLk+JXJFhUHVK2M/lX 1Wzi2xCEVMVozEQNmCt1gm1i0Xx1KahxpOg5g8LJU3lFofxVbVmvo7yF3OibSC/EQ2z7 iUQZWt3gkfQef4trIjOPXpR+6+HHwEgSPseeU220ToYQA/bS44hmqhYDJn8m0cJUfW/D ikMCuLHfE6I08/cSAI7AC5QlkePoq0/Hkoq7To8kVedR6NgBPJ1k2lzmG2sBbKw6sQIw 8xIu3M3Hdlh2+YrGhLyZC5rl8Nhy6WEn6PqjL4aI/NjiZhyNfZ+JTj5C3n3uWfTLvTIH GcNA== MIME-Version: 1.0 From: "H.J. Lu" Date: Wed, 5 Feb 2020 09:58:46 -0800 Message-ID: Subject: [PATCH] x86-64: Pass aggregates with only float/double in GPRs for MS_ABI To: GCC Patches , Anthony Green , Uros Bizjak X-IsSubscribed: yes MS_ABI requires passing aggregates with only float/double in integer registers. Checked gcc outputs against Clang and fixed: FAIL: libffi.bhaible/test-callback.c -W -Wall -Wno-psabi -DDGTEST=54 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized -O0 -DABI_NUM=FFI_GNUW64 -DABI_ATTR=MSABI execution test FAIL: libffi.bhaible/test-callback.c -W -Wall -Wno-psabi -DDGTEST=54 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized -O2 -DABI_NUM=FFI_GNUW64 -DABI_ATTR=MSABI execution test FAIL: libffi.bhaible/test-callback.c -W -Wall -Wno-psabi -DDGTEST=55 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized -O0 -DABI_NUM=FFI_GNUW64 -DABI_ATTR=MSABI execution test FAIL: libffi.bhaible/test-callback.c -W -Wall -Wno-psabi -DDGTEST=55 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized -O2 -DABI_NUM=FFI_GNUW64 -DABI_ATTR=MSABI execution test FAIL: libffi.bhaible/test-callback.c -W -Wall -Wno-psabi -DDGTEST=56 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized -O0 -DABI_NUM=FFI_GNUW64 -DABI_ATTR=MSABI execution test FAIL: libffi.bhaible/test-callback.c -W -Wall -Wno-psabi -DDGTEST=56 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized -O2 -DABI_NUM=FFI_GNUW64 -DABI_ATTR=MSABI execution test in libffi testsuite. OK for master and backports to GCC 8/9 branches? gcc/ PR target/85667 * config/i386/i386.c (function_arg_ms_64): Add a type argument. Don't return aggregates with only SFmode and DFmode in SSE register. (ix86_function_arg): Pass arg.type to function_arg_ms_64. gcc/testsuite/ PR target/85667 * gcc.target/i386/pr85667-10.c: New test. * gcc.target/i386/pr85667-7.c: Likewise. * gcc.target/i386/pr85667-8.c: Likewise. * gcc.target/i386/pr85667-9.c: Likewise. From e561fd8fcb46b8d8e40942c077e26ce120832747 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 5 Feb 2020 09:49:56 -0800 Subject: [PATCH] x86-64: Pass aggregates with only float/double in GPRs for MS_ABI MS_ABI requires passing aggregates with only float/double in integer registers. Checked gcc outputs against Clang and fixed: FAIL: libffi.bhaible/test-callback.c -W -Wall -Wno-psabi -DDGTEST=54 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized -O0 -DABI_NUM=FFI_GNUW64 -DABI_ATTR=MSABI execution test FAIL: libffi.bhaible/test-callback.c -W -Wall -Wno-psabi -DDGTEST=54 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized -O2 -DABI_NUM=FFI_GNUW64 -DABI_ATTR=MSABI execution test FAIL: libffi.bhaible/test-callback.c -W -Wall -Wno-psabi -DDGTEST=55 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized -O0 -DABI_NUM=FFI_GNUW64 -DABI_ATTR=MSABI execution test FAIL: libffi.bhaible/test-callback.c -W -Wall -Wno-psabi -DDGTEST=55 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized -O2 -DABI_NUM=FFI_GNUW64 -DABI_ATTR=MSABI execution test FAIL: libffi.bhaible/test-callback.c -W -Wall -Wno-psabi -DDGTEST=56 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized -O0 -DABI_NUM=FFI_GNUW64 -DABI_ATTR=MSABI execution test FAIL: libffi.bhaible/test-callback.c -W -Wall -Wno-psabi -DDGTEST=56 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized -O2 -DABI_NUM=FFI_GNUW64 -DABI_ATTR=MSABI execution test in libffi testsuite. gcc/ PR target/85667 * config/i386/i386.c (function_arg_ms_64): Add a type argument. Don't return aggregates with only SFmode and DFmode in SSE register. (ix86_function_arg): Pass arg.type to function_arg_ms_64. gcc/testsuite/ PR target/85667 * gcc.target/i386/pr85667-10.c: New test. * gcc.target/i386/pr85667-7.c: Likewise. * gcc.target/i386/pr85667-8.c: Likewise. * gcc.target/i386/pr85667-9.c: Likewise. --- gcc/config/i386/i386.c | 10 ++++-- gcc/testsuite/gcc.target/i386/pr85667-10.c | 21 +++++++++++++ gcc/testsuite/gcc.target/i386/pr85667-7.c | 36 ++++++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr85667-8.c | 21 +++++++++++++ gcc/testsuite/gcc.target/i386/pr85667-9.c | 36 ++++++++++++++++++++++ 5 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr85667-10.c create mode 100644 gcc/testsuite/gcc.target/i386/pr85667-7.c create mode 100644 gcc/testsuite/gcc.target/i386/pr85667-8.c create mode 100644 gcc/testsuite/gcc.target/i386/pr85667-9.c diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index ffda3e8fd21..f769cb8f75e 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -3153,7 +3153,7 @@ function_arg_64 (const CUMULATIVE_ARGS *cum, machine_mode mode, static rtx function_arg_ms_64 (const CUMULATIVE_ARGS *cum, machine_mode mode, - machine_mode orig_mode, bool named, + machine_mode orig_mode, bool named, const_tree type, HOST_WIDE_INT bytes) { unsigned int regno; @@ -3173,7 +3173,10 @@ function_arg_ms_64 (const CUMULATIVE_ARGS *cum, machine_mode mode, if (TARGET_SSE && (mode == SFmode || mode == DFmode)) { if (named) - regno = cum->regno + FIRST_SSE_REG; + { + if (type == NULL_TREE || !AGGREGATE_TYPE_P (type)) + regno = cum->regno + FIRST_SSE_REG; + } else { rtx t1, t2; @@ -3253,7 +3256,8 @@ ix86_function_arg (cumulative_args_t cum_v, const function_arg_info &arg) enum calling_abi call_abi = cum ? cum->call_abi : ix86_abi; if (call_abi == MS_ABI) - reg = function_arg_ms_64 (cum, mode, arg.mode, arg.named, bytes); + reg = function_arg_ms_64 (cum, mode, arg.mode, arg.named, + arg.type, bytes); else reg = function_arg_64 (cum, mode, arg.mode, arg.type, arg.named); } diff --git a/gcc/testsuite/gcc.target/i386/pr85667-10.c b/gcc/testsuite/gcc.target/i386/pr85667-10.c new file mode 100644 index 00000000000..e8f3026227d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85667-10.c @@ -0,0 +1,21 @@ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-O2 -masm=att" } */ +/* { dg-final { scan-assembler-times "movq\[ \t\]*%rcx, .*" 1 } } */ +/* { dg-final { scan-assembler-times "movq\[ \t\]*%rdx, .*" 1 } } */ +/* { dg-final { scan-assembler-times "movq\[ \t\]*%r8, .*" 1 } } */ +/* { dg-final { scan-assembler-times "movq\[ \t\]*%r9, .*" 1 } } */ +/* { dg-final { scan-assembler-times "addsd\[ \t]*40\\\(%rsp\\\), .*" 1 } } */ +/* { dg-final { scan-assembler-times "movq\[^\n\r\]*, %rax" 1 } } */ + +typedef struct +{ + double x; +} Double; + +Double __attribute__((ms_abi)) +fn1 (Double x1, Double x2, Double x3, Double x4, Double x5) +{ + Double v; + v.x = x1.x + x2.x + x3.x + x4.x + x5.x; + return v; +} diff --git a/gcc/testsuite/gcc.target/i386/pr85667-7.c b/gcc/testsuite/gcc.target/i386/pr85667-7.c new file mode 100644 index 00000000000..6bd860975a7 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85667-7.c @@ -0,0 +1,36 @@ +/* { dg-do run { target lp64 } } */ +/* { dg-options "-O2" } */ + +void abort (void); + +typedef struct +{ + float x; +} Float; + +Float __attribute__((ms_abi, noinline, noclone)) +fn1 (Float x1, Float x2, Float x3, Float x4, Float x5) +{ + Float v; + v.x = x1.x + x2.x + x3.x + x4.x + x5.x; + return v; +} +int main () +{ + Float a, a1, a2, a3, a4, a5; + float x1 = 1.1; + float x2 = 3.1; + float x3 = 4.2; + float x4 = 14.2; + float x5 = -7.2; + float x = x1 + x2 + x3 + x4 + x5; + a1.x = x1; + a2.x = x2; + a3.x = x3; + a4.x = x4; + a5.x = x5; + a = fn1 (a1, a2, a3, a4, a5); + if (a.x == x); + return 0; + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/pr85667-8.c b/gcc/testsuite/gcc.target/i386/pr85667-8.c new file mode 100644 index 00000000000..09a7593fdb3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85667-8.c @@ -0,0 +1,21 @@ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-O2 -masm=att" } */ +/* { dg-final { scan-assembler-times "movd\[ \t\]*%ecx, .*" 1 } } */ +/* { dg-final { scan-assembler-times "movd\[ \t\]*%edx, .*" 1 } } */ +/* { dg-final { scan-assembler-times "movd\[ \t\]*%r8d, .*" 1 } } */ +/* { dg-final { scan-assembler-times "movd\[ \t\]*%r9d, .*" 1 } } */ +/* { dg-final { scan-assembler-times "addss\[ \t]*40\\\(%rsp\\\), .*" 1 } } */ +/* { dg-final { scan-assembler-times "movd\[^\n\r\]*, %eax" 1 } } */ + +typedef struct +{ + float x; +} Float; + +Float __attribute__((ms_abi)) +fn1 (Float x1, Float x2, Float x3, Float x4, Float x5) +{ + Float v; + v.x = x1.x + x2.x + x3.x + x4.x + x5.x; + return v; +} diff --git a/gcc/testsuite/gcc.target/i386/pr85667-9.c b/gcc/testsuite/gcc.target/i386/pr85667-9.c new file mode 100644 index 00000000000..8c9279a18bf --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85667-9.c @@ -0,0 +1,36 @@ +/* { dg-do run { target lp64 } } */ +/* { dg-options "-O2" } */ + +void abort (void); + +typedef struct +{ + double x; +} Double; + +Double __attribute__((ms_abi, noinline, noclone)) +fn1 (Double x1, Double x2, Double x3, Double x4, Double x5) +{ + Double v; + v.x = x1.x + x2.x + x3.x + x4.x + x5.x; + return v; +} +int main () +{ + Double a, a1, a2, a3, a4, a5; + double x1 = 1.1; + double x2 = 3.1; + double x3 = 4.2; + double x4 = 14.2; + double x5 = -7.2; + double x = x1 + x2 + x3 + x4 + x5; + a1.x = x1; + a2.x = x2; + a3.x = x3; + a4.x = x4; + a5.x = x5; + a = fn1 (a1, a2, a3, a4, a5); + if (a.x == x); + return 0; + abort (); +} -- 2.24.1