From patchwork Wed Nov 15 09:46:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyu Wang X-Patchwork-Id: 1864118 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=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=b/EQrbDk; 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 4SVdcY0TP7z1yRG for ; Wed, 15 Nov 2023 20:47:24 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 21A933857C52 for ; Wed, 15 Nov 2023 09:47:22 +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 [134.134.136.31]) by sourceware.org (Postfix) with ESMTPS id 4DE343858C98 for ; Wed, 15 Nov 2023 09:47:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DE343858C98 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 4DE343858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=134.134.136.31 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700041631; cv=none; b=MMuvIcXRV91ZrQWn/3iUVw4e0KmlpRHGoXHu541DQ/MYjPb31AakS13aPrpI3hxhmyOPQP8p/RZMbIFo2apF4IuOpU7fQjunlVM7TvDJ3rJd4BnTofAOT7SplL8S36IEsrxurQBs5YOVbpWeskA4HrvkZCaJXSicJ6hFrOlLHwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700041631; c=relaxed/simple; bh=7eydAPM26+JtVSt/KxuCrlJ58nR8vRZQHBCN+NUh20U=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Y+VMLv52N/7Re5+SeowGYJcZ5RdSxh42Z5Z6bTeGZ/RSUVgoTccxcerSs599kDcEMGKqHDHQxUzywMd+FMt591qaxL1ZqE+XoRGm3s7KZDeZssLzRQqwURdhLdbsgz0KUP4JMYoPwj6LqfVKSNiWQqjG+jGNTXhyfU7ROjzu5Kg= 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=1700041629; x=1731577629; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7eydAPM26+JtVSt/KxuCrlJ58nR8vRZQHBCN+NUh20U=; b=b/EQrbDkVOmmIq8BTmUBP4XYA77eiPsGbyvjcWGGXpKcxFtlJDdd1zbq dyfSvD8iw6MoSgaQf5c1trRg/Hwk+MjAJRaIokTL2EpUY8WK7DEPH0Vjm MYesjGrIgwJvWOOoKjeedSc7ulCFhuIuYcZmoOj2NLAGmIjs4eltqz0uu GdQVpEELIPFkZr5OyN2eXI42IzCa2XlEVtc4CF/ca1+97MEX3ZcKWbqX7 bW1r7NTNO9ILpFk1Gm3na2zovlP+93K9g2P7l/MP7/NbmhApdwDkJXyKu InGTwRg8Qs/F9uw1HStI7Ml7Q9TfTJ+83j+LCIc/vaFEZd5BKXUVn5psE Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="455138345" X-IronPort-AV: E=Sophos;i="6.03,304,1694761200"; d="scan'208";a="455138345" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2023 01:47:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,304,1694761200"; d="scan'208";a="6105926" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orviesa002.jf.intel.com with ESMTP; 15 Nov 2023 01:47:07 -0800 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id AAA2A1005676; Wed, 15 Nov 2023 17:47:05 +0800 (CST) From: Hongyu Wang To: gcc-patches@gcc.gnu.org Cc: ubizjak@gmail.com, hongtao.liu@intel.com Subject: [PATCH 02/16] [APX NDD] Restrict TImode register usage when NDD enabled Date: Wed, 15 Nov 2023 17:46:51 +0800 Message-Id: <20231115094705.3976553-3-hongyu.wang@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20231115094705.3976553-1-hongyu.wang@intel.com> References: <20231115094705.3976553-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+incoming=patchwork.ozlabs.org@gcc.gnu.org Under APX NDD, previous TImode allocation will have issue that it was originally allocated using continuous pair, like rax:rdi, rdi:rdx. This will cause issue for all TImode NDD patterns. For NDD we will not assume the arithmetic operations like add have dependency between dest and src1, then write to 1st highpart rdi will be overrided by the 2nd lowpart rdi if 2nd lowpart rdi have different src as input, then the write to 1st highpart rdi will missed and cause miscompliation. To resolve this, under TARGET_APX_NDD we'd only allow register with even regno to be allocated with TImode, then TImode registers will be allocated with non-overlapping pairs. There could be some error for inline assembly if it forcely allocate __int128 with odd number general register. gcc/ChangeLog: * config/i386/i386.cc (ix86_hard_regno_mode_ok): Restrict even regno for TImode if APX NDD enabled. --- gcc/config/i386/i386.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 683ac643bc8..3779d5b1206 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -20824,6 +20824,16 @@ ix86_hard_regno_mode_ok (unsigned int regno, machine_mode mode) return true; return !can_create_pseudo_p (); } + /* With TImode we previously have assumption that src1/dest will use same + register, so the allocation of highpart/lowpart can be consecutive, and + 2 TImode insn would held their low/highpart in continuous sequence like + rax:rdx, rdx:rcx. This will not work for APX_NDD since NDD allows + different registers as dest/src1, when writes to 2nd lowpart will impact + the writes to 1st highpart, then the insn will be optimized out. So for + TImode pattern if we support NDD form, the allowed register number should + be even to avoid such mixed high/low part override. */ + else if (TARGET_APX_NDD && mode == TImode) + return regno % 2 == 0; /* We handle both integer and floats in the general purpose registers. */ else if (VALID_INT_MODE_P (mode) || VALID_FP_MODE_P (mode))