From patchwork Wed Dec 4 04:49:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 102346 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 575EA3858D3C for ; Wed, 4 Dec 2024 05:10:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 575EA3858D3C Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=iXPc/1Ly X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by sourceware.org (Postfix) with ESMTPS id 6D7063858CDB for ; Wed, 4 Dec 2024 05:08:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D7063858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6D7063858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::836 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733288895; cv=none; b=uudeB5ZUZvUWZAeLQ7GDmCpvsyD6S1CZ+TQoeWmpZU3TeZasG3AWJj7xWTYDIY2a+IOz/r/W6Hc3D7ZwVEA02Kt6VW8cf0N1O0dsmazgZAJruqwXJI3cms+yoA+E2fU1x2xDsVR2gnlwa3oB4Y/a3QnEUW9SuHMsfUJ0q2C8qow= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733288895; c=relaxed/simple; bh=b6jc/qeCC0S/T/JpyUpI009LQTLKUR9ZJ/sWerH1d4I=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=bPJgdfgHBt4PS1thF3dN53swz9ul3mhN0iN2fMLbOtwhPqFNEtMOtvW7W4gQU5QJyVuVeWCSiYgWKCB5vDh6kQv8BbekU3ixuYISmy9RyqjnWkUyOEUFYgSlDO8HDyZAxCVIteEyoW4kHvIaUe9w3WcAAXvHBpyE6axEND6miik= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D7063858CDB Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-46679337c08so31846661cf.3 for ; Tue, 03 Dec 2024 21:08:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733288894; x=1733893694; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ApfjwB2s759Pr+SY0RhRtb30IZxdMx67Pk+jl4WWaO4=; b=iXPc/1LymPGcj1ZWVvhXKWu6L4ZItVAPg11KqivD4/WC9XrkAD3JMRf0tnXMZCZ/tN MM2JrNvKMhtiyBBEkpAxqdUamd54ma6rVLMK7srM0cCiZFBZvSIbA19yIJCAg358N3Da PTLhxUu0/AvKANDjesVEO/7bEljeo18o20RJyZck5Ywan9BMcfIpwrB7hcOPHFrZ2MGl tsWuERzLjBjiPQEmplOP2DKRAa5VA/oFfZjsRYfsVRAiOEhvxZjVEjak5Mq2tBrTTDJe UnTSVemPw1/SixXBKv8TmmPnKxCMjFA+ncg3jcMPd5wlo5hPBHu+W9GEtVMje5pPF+gQ bBOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733288894; x=1733893694; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ApfjwB2s759Pr+SY0RhRtb30IZxdMx67Pk+jl4WWaO4=; b=HoXXuFGQrCOvfoz2JRy87Fp7ZzrHDhUzaAxK8uWu3ZvOVuv7qlK8TVuOjczExeKM/X ELmldDfP0UP2COqwZg8UBBcjEQLmh2/+kXwCebdeu8UrCK1S0cFeZ8NzwnmRozLZ0KKS VLXnjSMzgcqxXt/xDnQu+4t5moRr48jFxkK7X0BHMVJ3gopflmVMJt6d4DCiOdTDYPJ5 2wMzi0xP+AokIRWuCKTRyVIebMi/D3gC5HF31PREkuAXHGomHSIiTuxiAaHU+yjFP4dJ 3rCATyfivyB8zf8tKkJyH2ZrIjgqb/EBtrWLR/e0Insgb1dNrD0Uo8svl3OuKotBVYc8 eYew== X-Gm-Message-State: AOJu0YyAP8jrxpbE4G2MmwjMhY90uCPPEE1U0A5KdbdgfZGmu0doK/DQ sn/cia1BFH6suERJosxNyR45zb7DRHU6PYqDlVynDCKB8RiJKJLf X-Gm-Gg: ASbGncsqIwqi8SRuHxx4V1HZpGl2SgbMxHDRCUpOxIqe0cHA5WrYPed4tMEOVEa2izT fiu8iTeZ7YecaZJbN1b0aCMiWXRjxXHzuCzirfjGygpmMI8e5Z4RPZtu+DvLtHbD9GzfCOTQzsD /5HQ6YkHVYSIMTVdCmVVS+eD94Tqg5SKTN/HWElY2kbzNSgFXsXlrUwytKweFts78NgiB6xdzFE mXSv9EmWfGDv6RZ+RHT3oex7XTCVJy4+ImCmnD3EXF1ZbwuP7SvghGZLl3yV8u//QhjLdishYUT Y6JnzLsz7mcdNa6xEsOV3YCsptDag7Qu1+Z2/Q== X-Google-Smtp-Source: AGHT+IEKfZQ7z9vOsehOHfxdI/ynJcsJBtM9ZPfdTKjZVS7iSmf2nmlbz4w69fS5/Y9tuzczG0SF2A== X-Received: by 2002:a05:622a:1984:b0:466:948e:beec with SMTP id d75a77b69052e-4670c38fb9emr90173041cf.39.1733288894090; Tue, 03 Dec 2024 21:08:14 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.160.52]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-466c3fa58fesm69788441cf.0.2024.12.03.21.08.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 21:08:13 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id B45F0C05A5; Wed, 04 Dec 2024 12:49:51 +0800 (CST) From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com, jeffreyalaw@gmail.com, jakub@redhat.com, richard.sandiford@arm.com, matz@suse.de Subject: [PATCH v5 3/7] Use incoming small integer argument type if possible Date: Wed, 4 Dec 2024 12:49:47 +0800 Message-ID: <20241204044951.509713-4-hjl.tools@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241204044951.509713-1-hjl.tools@gmail.com> References: <20241204044951.509713-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3019.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org For targets, like x86, which define TARGET_PROMOTE_PROTOTYPES to return true, all integer arguments smaller than int are passed as int: [hjl@gnu-tgl-3 pr14907]$ cat x.c extern int baz (char c1); int foo (char c1) { return baz (c1); } [hjl@gnu-tgl-3 pr14907]$ gcc -S -O2 -m32 x.c [hjl@gnu-tgl-3 pr14907]$ cat x.s .file "x.c" .text .p2align 4 .globl foo .type foo, @function foo: .LFB0: .cfi_startproc movsbl 4(%esp), %eax movl %eax, 4(%esp) jmp baz .cfi_endproc .LFE0: .size foo, .-foo .ident "GCC: (GNU) 14.2.1 20240912 (Red Hat 14.2.1-3)" .section .note.GNU-stack,"",@progbits [hjl@gnu-tgl-3 pr14907]$ But integer promotion: movsbl 4(%esp), %eax movl %eax, 4(%esp) isn't necessary if incoming arguments and outgoing arguments are the same. Use the incoming small integer argument type for the incoming argument if the incoming small integer argument is copied to the outgoing argument without any modification. gcc/ PR middle-end/14907 * calls.cc: (get_small_int_arg_type): New function. (initialize_argument_information): Call get_small_int_arg_type to get the small integer argument type. gcc/testsuite/ PR middle-end/14907 * gcc.target/i386/pr14907-1.c: New test. * gcc.target/i386/pr14907-2.c: Likewise. * gcc.target/i386/pr14907-3.c: Likewise. * gcc.target/i386/pr14907-4.c: Likewise. * gcc.target/i386/pr14907-5.c: Likewise. * gcc.target/i386/pr14907-6.c: Likewise. * gcc.target/i386/pr14907-7.c: Likewise. * gcc.target/i386/pr14907-8.c: Likewise. * gcc.target/i386/pr14907-9.c: Likewise. * gcc.target/i386/pr14907-10.c: Likewise. * gcc.target/i386/pr14907-11.c: Likewise. * gcc.target/i386/pr14907-12.c: Likewise. * gcc.target/i386/pr14907-13.c: Likewise. * gcc.target/i386/pr14907-14.c: Likewise. * gcc.target/i386/pr14907-15.c: Likewise. * gcc.target/i386/pr14907-16.c: Likewise. Signed-off-by: H.J. Lu --- gcc/calls.cc | 29 +++++++++++++++++++++- gcc/testsuite/gcc.target/i386/pr14907-1.c | 21 ++++++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-10.c | 23 +++++++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-11.c | 12 +++++++++ gcc/testsuite/gcc.target/i386/pr14907-12.c | 17 +++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-13.c | 12 +++++++++ gcc/testsuite/gcc.target/i386/pr14907-14.c | 17 +++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-15.c | 26 +++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-16.c | 24 ++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-2.c | 21 ++++++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-3.c | 21 ++++++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-4.c | 21 ++++++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-5.c | 21 ++++++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-6.c | 21 ++++++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-7.c | 22 ++++++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-8.c | 23 +++++++++++++++++ gcc/testsuite/gcc.target/i386/pr14907-9.c | 22 ++++++++++++++++ 17 files changed, 352 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-1.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-10.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-11.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-12.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-13.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-14.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-15.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-16.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-2.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-3.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-4.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-5.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-6.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-7.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-8.c create mode 100644 gcc/testsuite/gcc.target/i386/pr14907-9.c diff --git a/gcc/calls.cc b/gcc/calls.cc index 78ead6fd4ed..d0f6f2bdfd6 100644 --- a/gcc/calls.cc +++ b/gcc/calls.cc @@ -1280,6 +1280,33 @@ maybe_complain_about_tail_call (tree call_expr, const char *reason) CALL_EXPR_MUST_TAIL_CALL (call_expr) = 0; } +/* Return the original integer type if ARG is copied from the incoming + argument. Otherwise return integer_type_node. */ + +static tree +get_small_int_arg_type (tree arg) +{ + if (TREE_CODE (arg) != SSA_NAME) + return integer_type_node; + + if (!SSA_NAME_IS_DEFAULT_DEF (arg)) + return integer_type_node; + + tree var = SSA_NAME_VAR (arg); + if (TREE_CODE (var) != PARM_DECL) + return integer_type_node; + if (TYPE_MODE (TREE_TYPE (arg)) != TYPE_MODE (DECL_ARG_TYPE (var))) + return integer_type_node; + + /* Use the incoming small integer argument type for the outgoing + argument. If callee is a global function, we always properly + extend the incoming small integer arguments in callee. If + callee is a local function, since DECL_ARG_TYPE has the original + small integer type, we will extend the incoming small integer + arguments in callee if needed. */ + return TREE_TYPE (arg); +} + /* Fill in ARGS_SIZE and ARGS array based on the parameters found in CALL_EXPR EXP. @@ -1391,7 +1418,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, else if (promote_p && INTEGRAL_TYPE_P (type) && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)) - type = integer_type_node; + type = get_small_int_arg_type (args[i].tree_value); /* If TYPE is a transparent union or record, pass things the way we would pass the first field of the union or record. We have diff --git a/gcc/testsuite/gcc.target/i386/pr14907-1.c b/gcc/testsuite/gcc.target/i386/pr14907-1.c new file mode 100644 index 00000000000..231819ed675 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "x86*" "" "" { target *-*-linux* *-*-gnu* } {^\t?\.} } } */ + +/* +x86*foo: +x86*.LFB0: +x86* .cfi_startproc +x86* jmp baz +x86* .cfi_endproc +x86*... +*/ + +extern int baz (char); + +int +foo (char c1) +{ + return baz (c1); +} diff --git a/gcc/testsuite/gcc.target/i386/pr14907-10.c b/gcc/testsuite/gcc.target/i386/pr14907-10.c new file mode 100644 index 00000000000..099c4dc81d1 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-10.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "ia32*" "" "" { target { { *-*-linux* *-*-gnu* } && ia32 } } {^\t?\.} } } */ + +/* +ia32*foo: +ia32*.LFB0: +ia32* .cfi_startproc +ia32* movsbl 4\(%esp\), %eax +ia32* movl %eax, 4\(%esp\) +ia32* jmp baz +ia32* .cfi_endproc +ia32*... +*/ + +extern int baz (short); + +int +foo (char c1) +{ + return baz (c1); +} diff --git a/gcc/testsuite/gcc.target/i386/pr14907-11.c b/gcc/testsuite/gcc.target/i386/pr14907-11.c new file mode 100644 index 00000000000..12ac165c298 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-11.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern int baz (char, char); + +int +foo (char c1, char c2) +{ + return baz (c1, c2) + 1; +} + +/* { dg-final { scan-assembler-not "movsbl" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr14907-12.c b/gcc/testsuite/gcc.target/i386/pr14907-12.c new file mode 100644 index 00000000000..6cda72ef3a2 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-12.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct s +{ + char c[20]; +}; + +extern struct s baz (char, char); + +struct s +foo (char c1, char c2) +{ + return baz (c1, c2); +} + +/* { dg-final { scan-assembler-not "movsbl" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr14907-13.c b/gcc/testsuite/gcc.target/i386/pr14907-13.c new file mode 100644 index 00000000000..b4130fdcb57 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-13.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern int baz (char, char, ...); + +int +foo (char c1, char c2) +{ + return baz (c1, c2, 0, 0, 0, 1); +} + +/* { dg-final { scan-assembler-not "movsbl" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr14907-14.c b/gcc/testsuite/gcc.target/i386/pr14907-14.c new file mode 100644 index 00000000000..9b8d7a7607d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-14.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct s +{ + char c[20]; +}; + +extern struct s baz (char, char, ...); + +struct s +foo (char c1, char c2) +{ + return baz (c1, c2, 0, 1); +} + +/* { dg-final { scan-assembler-not "movsbl" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr14907-15.c b/gcc/testsuite/gcc.target/i386/pr14907-15.c new file mode 100644 index 00000000000..08bc4ea9ac8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-15.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "x64*" "" "" { target { { *-*-linux* *-*-gnu* } && { ! ia32 } } } {^\t?\.} } } */ + +/* +x64*foo: +x64*.LFB1: +x64* .cfi_startproc +x64* jmp baz +x64* .cfi_endproc +x64*... +*/ + + __attribute__ ((noinline)) +static int +baz (char c1) +{ + return c1; +} + +int +foo (char c1) +{ + return baz (c1); +} diff --git a/gcc/testsuite/gcc.target/i386/pr14907-16.c b/gcc/testsuite/gcc.target/i386/pr14907-16.c new file mode 100644 index 00000000000..48c255ffb20 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-16.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "x64*" "" "" { target { { *-*-linux* *-*-gnu* } && { ! ia32 } } } {^\t?\.} } } */ + +/* +x64*foo: +x64*.LFB0: +x64* .cfi_startproc +x64* andl \$1, %edi +x64* jmp baz +x64* .cfi_endproc +x64*... +*/ + +#include + +extern int baz (bool); + +int +foo (int c1) +{ + return baz (c1 & 0x1); +} diff --git a/gcc/testsuite/gcc.target/i386/pr14907-2.c b/gcc/testsuite/gcc.target/i386/pr14907-2.c new file mode 100644 index 00000000000..5da7b029279 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-2.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "x86*" "" "" { target *-*-linux* *-*-gnu* } {^\t?\.} } } */ + +/* +x86*foo: +x86*.LFB0: +x86* .cfi_startproc +x86* jmp baz +x86* .cfi_endproc +x86*... +*/ + +extern int baz (int, int, int, int, int, int, char, char); + +int +foo (int a1, int a2, int a3, int a4, int a5, int a6, char c1, char c2) +{ + return baz (a1, a2, a3, a4, a5, a6, c1, c2); +} diff --git a/gcc/testsuite/gcc.target/i386/pr14907-3.c b/gcc/testsuite/gcc.target/i386/pr14907-3.c new file mode 100644 index 00000000000..a8fb13f28f8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-3.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "x86*" "" "" { target *-*-linux* *-*-gnu* } {^\t?\.} } } */ + +/* +x86*c1: +x86*.LFB0: +x86* .cfi_startproc +x86* jmp c2 +x86* .cfi_endproc +x86*... +*/ + +extern char c2 (char); + +char +c1 (char c) +{ + return c2 (c); +} diff --git a/gcc/testsuite/gcc.target/i386/pr14907-4.c b/gcc/testsuite/gcc.target/i386/pr14907-4.c new file mode 100644 index 00000000000..b5fb92fefcc --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-4.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "x86*" "" "" { target *-*-linux* *-*-gnu* } {^\t?\.} } } */ + +/* +x86*foo: +x86*.LFB0: +x86* .cfi_startproc +x86* jmp baz +x86* .cfi_endproc +x86*... +*/ + +extern int baz (short); + +int +foo (short c1) +{ + return baz (c1); +} diff --git a/gcc/testsuite/gcc.target/i386/pr14907-5.c b/gcc/testsuite/gcc.target/i386/pr14907-5.c new file mode 100644 index 00000000000..d9abb5c8cfb --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-5.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "x86*" "" "" { target *-*-linux* *-*-gnu* } {^\t?\.} } } */ + +/* +x86*foo: +x86*.LFB0: +x86* .cfi_startproc +x86* jmp baz +x86* .cfi_endproc +x86*... +*/ + +extern int baz (int, int, int, int, int, int, short, short); + +int +foo (int a1, int a2, int a3, int a4, int a5, int a6, short c1, short c2) +{ + return baz (a1, a2, a3, a4, a5, a6, c1, c2); +} diff --git a/gcc/testsuite/gcc.target/i386/pr14907-6.c b/gcc/testsuite/gcc.target/i386/pr14907-6.c new file mode 100644 index 00000000000..b6d0183656a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-6.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "x86*" "" "" { target *-*-linux* *-*-gnu* } {^\t?\.} } } */ + +/* +x86*c1: +x86*.LFB0: +x86* .cfi_startproc +x86* jmp c2 +x86* .cfi_endproc +x86*... +*/ + +extern short c2 (short); + +short +c1 (short c) +{ + return c2 (c); +} diff --git a/gcc/testsuite/gcc.target/i386/pr14907-7.c b/gcc/testsuite/gcc.target/i386/pr14907-7.c new file mode 100644 index 00000000000..fbf511f691e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-7.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "x64*" "" "" { target { { *-*-linux* *-*-gnu* } && { ! ia32 } } } {^\t?\.} } } */ + +/* +x64*foo: +x64*.LFB0: +x64* .cfi_startproc +x64* movsbl %dil, %edi +x64* jmp baz +x64* .cfi_endproc +x64*... +*/ + +extern int baz (int); + +int +foo (char c1) +{ + return baz (c1); +} diff --git a/gcc/testsuite/gcc.target/i386/pr14907-8.c b/gcc/testsuite/gcc.target/i386/pr14907-8.c new file mode 100644 index 00000000000..7d2611398c0 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-8.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "ia32*" "" "" { target { { *-*-linux* *-*-gnu* } && ia32 } } {^\t?\.} } } */ + +/* +ia32*foo: +ia32*.LFB0: +ia32* .cfi_startproc +ia32* movsbl 4\(%esp\), %eax +ia32* movl %eax, 4\(%esp\) +ia32* jmp baz +ia32* .cfi_endproc +ia32*... +*/ + +extern int baz (int); + +int +foo (char c1) +{ + return baz (c1); +} diff --git a/gcc/testsuite/gcc.target/i386/pr14907-9.c b/gcc/testsuite/gcc.target/i386/pr14907-9.c new file mode 100644 index 00000000000..a22383694bf --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr14907-9.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "x64*" "" "" { target { { *-*-linux* *-*-gnu* } && { ! ia32 } } } {^\t?\.} } } */ + +/* +x64*foo: +x64*.LFB0: +x64* .cfi_startproc +x64* movsbl %dil, %edi +x64* jmp baz +x64* .cfi_endproc +x64*... +*/ + +extern int baz (short); + +int +foo (char c1) +{ + return baz (c1); +}