From patchwork Wed Dec 6 08:06:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyu Wang X-Patchwork-Id: 174385 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3954555vqy; Wed, 6 Dec 2023 00:10:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4AaqYn6ROhdNlJt5taT3xj1sogXjoYOkwnx8EpwlAZ9gNSsz6su30SoTAzuuHVBrEimRX X-Received: by 2002:a0c:f60a:0:b0:67a:a721:b18c with SMTP id r10-20020a0cf60a000000b0067aa721b18cmr460093qvm.71.1701850203236; Wed, 06 Dec 2023 00:10:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701850203; cv=pass; d=google.com; s=arc-20160816; b=n6hUtKwZGsQkcvSQsr19ExLfdCA/zB8zAIMRSxeByPPFLDuZUmqXalVkWWxO4NbsDS bN3etyHrA+q7impjzHJTRmtTUlrTXf8W6OCOM+g8C1JHE9wBaANKROMjJq06A9SPrBxk ZtPPaP54/+rKoMIhlKqm8yBTMCWdJCSBL4JXhvfFjURg8GMYcUe31BD73dIpsUoThEK3 7Aa6ty26fnGknkkG5YvO1nHZ79kof8bxK2WldjMpHBucbtXsduqLCHBRFuX0Te+lPwpK sKap98ti/dYYm6Ee6M8BhyC0PTu9SNpKjlh8mw4sVkjFGkeibf39+cu81ITPql2Pmcyb m8wA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=+NqvhAe3TDML1urkH80iEDa4FnrsTPmcK9NIi976JrA=; fh=n8eNxIWSYJwy/CU3QSXzDvE/zeEoomCGojuOcYEQEyQ=; b=ZsEZuBHVrfSAdEf/e1FkPgm/Qo+uKokugOMC0KwvfD+my1rhrQm5K6GLYPs4wNsL9d P+yyz/BdP1Mikxs70RwfKxTQuervevSW5NGscZTs6BsOGxc/YY8auxC7tVEs4Him+xwo x6nRm03QteLFYfofgWZ9WSqk0EmtaYgMMCTWDbC3Y+jWQWqkbPOkB9Rw0mkxefgAe5Jc SFn59GOS6gSDhhd9oZehsE2rGUnYivbhpHNMeGklB8M7RIemxzLJ1DJ0r4Sw6gvl8R/s cze/opue9aunrzhc+njIFyKt2AYHBSVXTaptf0Y6OFLWx8vGdaUkrYtdk1UaGaXNhYpn FDfg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=f1B9CGtq; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l10-20020a0ce6ca000000b0067a235c49dfsi13291000qvn.542.2023.12.06.00.10.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 00:10:03 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=f1B9CGtq; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 79117384F987 for ; Wed, 6 Dec 2023 08:09:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by sourceware.org (Postfix) with ESMTPS id 9BD413858020 for ; Wed, 6 Dec 2023 08:08:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9BD413858020 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9BD413858020 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701850124; cv=none; b=ubt5swoOLb9QOEA8w0qiaTgk6qmefKvfHUdOUtG0goNNW96X2OLU3pOe87Rbw6/AvqVNCP5iL5UKHJOJGxgPX5e/3IIlQtsWx0U9rdJY3o4AvwR2XQxuh4wcSyUSPqGmbpq/pPrE/pMtiTo621kCL0gOdWb0ef0QuKIiqRGK/K8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701850124; c=relaxed/simple; bh=VmodS8O6oqWK9x2p7cugr2PrJmtY8up3GEdC6M/YPXg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=wcJwVwUH7+GAjHlXkSuUURpMvuIt2y8dr9L2+LE+9lo7hAEtBdNtxQ203BCx9wdfwNelV2GgA2O857UOaLaferdjiuRDKsfuyNzU4gZ81mCUkdco+RrXtpNItjLMR1nP8X31+tW5NHuZKUEqDOxKpYrbDtUeO0QC5zvfb/RhzGU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701850123; x=1733386123; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VmodS8O6oqWK9x2p7cugr2PrJmtY8up3GEdC6M/YPXg=; b=f1B9CGtqD0zy7qZtH0J5jphCHNoGKfmqKlb0MuHRrbe4MUPaBcjm3wND bgbktstpeSoSwOUUM9k4kbvIfftObYu4WmbF1E1AaGez9dCllPvt2P5Du xar03MHgGA8RAfQQXrmAAa/HdewYar7QKAQIm0KGWW/VjJQ4sqU3TtoNf 4Dr+pCRf01kMasNSR/aSH9GpRw9BPs4ZUPFTMPINy4+uD+Mh8VIr+XlSe u+xRAN14bjRGHBvPMVOhVxT4a8BggVLI8mAtn9sh3OidAz2Uca1vu+XCe mNXCuIJFweZ7OBGeH/VLtQAuJ3znBDpFC4ERIWHrPTSdaRuIdC1fwcY1h g==; X-IronPort-AV: E=McAfee;i="6600,9927,10915"; a="1085453" X-IronPort-AV: E=Sophos;i="6.04,254,1695711600"; d="scan'208";a="1085453" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2023 00:08:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10915"; a="1102737736" X-IronPort-AV: E=Sophos;i="6.04,254,1695711600"; d="scan'208";a="1102737736" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga005.fm.intel.com with ESMTP; 06 Dec 2023 00:08:37 -0800 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 8DA25100568F; Wed, 6 Dec 2023 16:08:36 +0800 (CST) From: Hongyu Wang To: gcc-patches@gcc.gnu.org Cc: ubizjak@gmail.com, hongtao.liu@intel.com Subject: [PATCH 03/16] [APX NDD] Disable seg_prefixed memory usage for NDD add Date: Wed, 6 Dec 2023 16:06:23 +0800 Message-Id: <20231206080636.178863-4-hongyu.wang@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20231206080636.178863-1-hongyu.wang@intel.com> References: <20231206080636.178863-1-hongyu.wang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, SPF_HELO_NONE, SPF_SOFTFAIL, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784519278604015348 X-GMAIL-MSGID: 1784519278604015348 NDD uses evex prefix, so when segment prefix is also applied, the instruction could excceed its 15byte limit, especially adding immediates. This could happen when "e" constraint accepts any UNSPEC_TPOFF/UNSPEC_NTPOFF constant and it will add the offset to segment register, which will be encoded using segment prefix. Disable those *POFF constant usage in NDD add alternatives with new constraint. gcc/ChangeLog: * config/i386/constraints.md (je): New constraint. * config/i386/i386-protos.h (x86_poff_operand_p): New function to check any *POFF constant in operand. * config/i386/i386.cc (x86_poff_operand_p): New prototype. * config/i386/i386.md (*add_1): Split out je alternative for add. --- gcc/config/i386/constraints.md | 5 +++++ gcc/config/i386/i386-protos.h | 1 + gcc/config/i386/i386.cc | 25 +++++++++++++++++++++++++ gcc/config/i386/i386.md | 8 ++++---- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md index cbee31fa40a..f4c3c3dd952 100644 --- a/gcc/config/i386/constraints.md +++ b/gcc/config/i386/constraints.md @@ -433,3 +433,8 @@ (define_address_constraint "jb" (define_register_constraint "jc" "TARGET_APX_EGPR && !TARGET_AVX ? GENERAL_GPR16 : GENERAL_REGS") + +(define_constraint "je" + "@internal constant that do not allow any unspec global offsets" + (and (match_operand 0 "x86_64_immediate_operand") + (match_test "!x86_poff_operand_p (op)"))) diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index a9d0c568bba..7dfeb6af225 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -66,6 +66,7 @@ extern bool x86_extended_QIreg_mentioned_p (rtx_insn *); extern bool x86_extended_reg_mentioned_p (rtx); extern bool x86_extended_rex2reg_mentioned_p (rtx); extern bool x86_evex_reg_mentioned_p (rtx [], int); +extern bool x86_poff_operand_p (rtx); extern bool x86_maybe_negate_const_int (rtx *, machine_mode); extern machine_mode ix86_cc_mode (enum rtx_code, rtx, rtx); diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 7c5cab4e2c6..8aa33aef7e1 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -23331,6 +23331,31 @@ x86_evex_reg_mentioned_p (rtx operands[], int nops) return false; } +/* Return true when rtx operand does not contain any UNSPEC_*POFF related + constant to avoid APX_NDD instructions excceed encoding length limit. */ +bool +x86_poff_operand_p (rtx operand) +{ + if (GET_CODE (operand) == CONST) + { + rtx op = XEXP (operand, 0); + if (GET_CODE (op) == PLUS) + op = XEXP (op, 0); + + if (GET_CODE (op) == UNSPEC) + { + int unspec = XINT (op, 1); + return (unspec == UNSPEC_NTPOFF + || unspec == UNSPEC_TPOFF + || unspec == UNSPEC_DTPOFF + || unspec == UNSPEC_GOTTPOFF + || unspec == UNSPEC_GOTNTPOFF + || unspec == UNSPEC_INDNTPOFF); + } + } + return false; +} + /* If profitable, negate (without causing overflow) integer constant of mode MODE at location LOC. Return true in this case. */ bool diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 1e846183347..a1626121227 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -6418,10 +6418,10 @@ (define_insn_and_split "*add3_doubleword_concat_zext" "split_double_mode (mode, &operands[0], 1, &operands[0], &operands[5]);") (define_insn "*add_1" - [(set (match_operand:SWI48 0 "nonimmediate_operand" "=rm,r,r,r,r,r") + [(set (match_operand:SWI48 0 "nonimmediate_operand" "=rm,r,r,r,r,r,r,r") (plus:SWI48 - (match_operand:SWI48 1 "nonimmediate_operand" "%0,0,r,r,rm,r") - (match_operand:SWI48 2 "x86_64_general_operand" "re,BM,0,le,re,BM"))) + (match_operand:SWI48 1 "nonimmediate_operand" "%0,0,r,r,rm,r,m,r") + (match_operand:SWI48 2 "x86_64_general_operand" "re,BM,0,le,r,e,je,BM"))) (clobber (reg:CC FLAGS_REG))] "ix86_binary_operator_ok (PLUS, mode, operands, TARGET_APX_NDD)" @@ -6457,7 +6457,7 @@ (define_insn "*add_1" : "add{}\t{%2, %0|%0, %2}"; } } - [(set_attr "isa" "*,*,*,*,apx_ndd,apx_ndd") + [(set_attr "isa" "*,*,*,*,apx_ndd,apx_ndd,apx_ndd,apx_ndd") (set (attr "type") (cond [(eq_attr "alternative" "3") (const_string "lea")