From patchwork Tue Feb 13 19:58:00 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: 1898445 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=N9J6MLt5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZBw04ZZsz23hT for ; Wed, 14 Feb 2024 06:58:23 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5D9383857C67 for ; Tue, 13 Feb 2024 19:58:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id D9DB33857C65 for ; Tue, 13 Feb 2024 19:58:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D9DB33857C65 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 D9DB33857C65 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::433 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707854286; cv=none; b=utFzzCpZYdqbf42/StEhDS9YQ+Tx/DJHuyShRb1xpLccXNus1ZG5tuPFrJWqvno+IHDoh5CO3QD96Gg9324sEBUXAru02lKVWijlIoOE0JWUxGBuXcczpyfEo4UWvxn7j9YNU9uyIq/74BUPQXf4u4G/UVQGGm5YZtsULSUffVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707854286; c=relaxed/simple; bh=hHUv59mrIHT4kMMwTvFCspbz1EyjQzRndgFzRQqpZCo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hqzwRmXxyTWB+WFTW7YtdCrOJMmsm8nKLep7LiGxaXFQ1SnmbSNAJGJCu3ybKtjww0Lg/t9NF/jfeEBc2mHFKUpiFWKqs3raUwhaK7nTjQl+yYzZQBUBGa/oOnRRHL7ZtActM2F68KVk2IFPfZv8xBFEiYCVuKqzB/T+fpKgcYc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6e09493eb8eso73892b3a.1 for ; Tue, 13 Feb 2024 11:58:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707854283; x=1708459083; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=q3d4bhueCUfcAlvASFe6P9BYSugmOcIb6tJ1MVqtGb8=; b=N9J6MLt5VAZy5Ou07Ea7NexuhU1T+Ru+SI3VWP7/gmfwDtCMsbCgotlot4rWJ2dpR0 Kp0MWiDSHZ/NW3JoURf3CrsPYeS1QYf5unh8mrcGHpCWPSPJIdZGHTh1Bp7ZCtvyZSaX sR0PmtkFZTUGDAV7QmTwbF2mewVh7Q6hqNHt3YivP8XvNYn74N1IWr7cWUWgY3BvwtlC qHdenMZHb4x3oSxBwrbsUd8NW7Yo6YPqKyL4H8Us1VxYbD/JCerKE/2OWpANZfXEmE3K xT8m+Iyx0IV8q4MeVG2lX6YMoFHmRWoyM6WeLErjm9OWW1lwKe/+8d8JA4Kzdggnttdt MCGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707854283; x=1708459083; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=q3d4bhueCUfcAlvASFe6P9BYSugmOcIb6tJ1MVqtGb8=; b=h1cvRTzM6PB7j5eDN8qMPjQlUhGn7KF0v1dzj+0TGLY1XIa/usNKQlu9b8tCB59BS0 NHF7Df5ylnuU9KoMMlqTg87HfxXzB8Wrp/RDxg/qMcoozL193uPOo0+00z+bfC9n1kIP j2BvPHk/leXCD9H+sZB7ux1ETTDwMqZXuC/e5OMmx9kWrW8ryit7r0qBjpErwAWvsr5j Kmluoswq5yoWivVeTziaPUWIWDeNP+REv8j1kBLciu5ekvN7bVSCcxvfUGtutQxYrgSm 0A0Hwu12rXA/q9xgFjfrhWNV7eiVUP7Cs+JzyC/Hc7nAsHLekI7javvuGecNCTl0ddMa rpeQ== X-Gm-Message-State: AOJu0Ywud/Fg9cPhxxykWv4eL5/grrqABK6twWNJALp+8eHuiH/eIQ3M OJsAgo6TyuJG/oU9FkmBK/Ougicgaz5y3sBHKlS8O/ruoGX732JEqJWV3rvw X-Google-Smtp-Source: AGHT+IEIaLF5Tj34sF6WAdsCnQIoYMx5WfrV3NDHAQHDPCfWUZXLV0w8TmsbmGnz8INw1JI3+yJwqw== X-Received: by 2002:a05:6a21:3512:b0:19e:ab8e:b3a4 with SMTP id zc18-20020a056a21351200b0019eab8eb3a4mr5111056pzb.24.1707854283160; Tue, 13 Feb 2024 11:58:03 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWQBo+HorJMg4dvjh4xobkNdvdAPqCIJ0RjoxMdgP1gNyCqDXmJ19paFHcK9viJDARTSfWfzTIZbIXKPtZdCPwA79b/LsM= Received: from gnu-cfl-3.localdomain ([172.56.168.224]) by smtp.gmail.com with ESMTPSA id 75-20020a63004e000000b005cd835182c5sm2784064pga.79.2024.02.13.11.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 11:58:01 -0800 (PST) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 94B30740146; Tue, 13 Feb 2024 11:58:00 -0800 (PST) From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: jakub@redhat.com, hongtao.liu@intel.com Subject: [PATCH] x86-64: Use push2/pop2 only if the incoming stack is 16-byte aligned Date: Tue, 13 Feb 2024 11:58:00 -0800 Message-ID: <20240213195800.4145414-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3021.8 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, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Since push2/pop2 requires 16-byte stack alignment, don't use them if the incoming stack isn't 16-byte aligned. gcc/ PR target/113876 * config/i386/i386.cc (ix86_pro_and_epilogue_can_use_push2pop2): Return false if the incoming stack isn't 16-byte aligned. gcc/testsuite/ PR target/113876 * gcc.target/i386/pr113876.c: New test. --- gcc/config/i386/i386.cc | 6 ++++++ gcc/testsuite/gcc.target/i386/pr113876.c | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/pr113876.c diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index dbb26e8f76a..a4e12602f70 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -6807,6 +6807,12 @@ get_probe_interval (void) static bool ix86_pro_and_epilogue_can_use_push2pop2 (int nregs) { + /* Use push2/pop2 only if the incoming stack is 16-byte aligned. */ + unsigned int incoming_stack_boundary + = (crtl->parm_stack_boundary > ix86_incoming_stack_boundary + ? crtl->parm_stack_boundary : ix86_incoming_stack_boundary); + if (incoming_stack_boundary % 128 != 0) + return false; int aligned = cfun->machine->fs.sp_offset % 16 == 0; return TARGET_APX_PUSH2POP2 && !cfun->machine->frame.save_regs_using_mov diff --git a/gcc/testsuite/gcc.target/i386/pr113876.c b/gcc/testsuite/gcc.target/i386/pr113876.c new file mode 100644 index 00000000000..fbf26f6ab8f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr113876.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target { lp64 } } } */ +/* { dg-options "-O -mapxf -mpreferred-stack-boundary=3 -finstrument-functions -mcmodel=large" } */ + +void +bar (unsigned long *p) +{ + p[0] = 0; + p[1] = 0; + p[2] = 0; +}