From patchwork Fri Jul 26 06:33:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jiang, Haochen" X-Patchwork-Id: 1965195 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=YZoaKFJP; 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 4WVdJQ14VYz1yY5 for ; Fri, 26 Jul 2024 16:34:14 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4844B3858294 for ; Fri, 26 Jul 2024 06:34:12 +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.10]) by sourceware.org (Postfix) with ESMTPS id 872473858D20 for ; Fri, 26 Jul 2024 06:33:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 872473858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 872473858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721975633; cv=none; b=x1z3k9gLu5cTZBuua7l+5IXtjjoMLDJg2CVFoDEfuMUYajR+h8pW27Rs4jplqWy2ac0RQL/AAVBfOzmJ2iwW4XUmchEODQ194z+LBuZ1uNcxB8c7Q5R2LziN+aOeMYoHe68a1WHYcZOLkdB1AmumiTsv7UJ9leKKfnW/aNzTyEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721975633; c=relaxed/simple; bh=6iPtrvt9CpQ3JBjXHxU1DDaJIPqhyJWKkLlhekSVlaA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=MgiyF+C+o1Ul6zLu0IngKLrOF2S6wb2qi5EE58ibVbVhMD91b26fjxPYHU9VlavMxou/zp7uzBVfVXBVsjPVhpWBiq/v6kgHQdHjxVer3C82hoqBQ/0cky+YAptH7oRUuY5+f/InsvqPdVIGOdmyGp2jE5L96G2l7Yblw2xxCSo= 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=1721975632; x=1753511632; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=6iPtrvt9CpQ3JBjXHxU1DDaJIPqhyJWKkLlhekSVlaA=; b=YZoaKFJPsDQtMeKSFjdzkAhbl4c3ulkYAWTsmqH8sq2NKDv8f2F7Q7B0 6ideBLn7gF1DUWINdy6K48vR5XhPZWBRAquKJb8mE9qIdyXw9OF14W7Zo pHpIWyD6nvtLxRLzSqZtDi+SzS0UeqgPJJWqKer82HG9pw6t9rRCj4brI 8xj02Y8W0SSfzrOkZggvQ6I8WetXoNEvybwwWlPwYFdgyQ4dj+YxN1kFQ sO4ICPtopMZXkR0g2cbm+9ReHzHp6gE06fiCHRsgvqMtyevpFMlBHwSNR W3rfkqnQr5t8VCkqwuOwXDgFL9pPn07KUuAH0tF0cuZFJ9hSOkkbzPTEE A==; X-CSE-ConnectionGUID: NrlNWbBDRy+OPJ2RAEotpg== X-CSE-MsgGUID: 3y177ekJSu+iDzEl95JcfA== X-IronPort-AV: E=McAfee;i="6700,10204,11144"; a="37225474" X-IronPort-AV: E=Sophos;i="6.09,238,1716274800"; d="scan'208";a="37225474" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2024 23:33:51 -0700 X-CSE-ConnectionGUID: 6r3B256lQjWkg44YvpV9Lg== X-CSE-MsgGUID: c4IlhFOUQXe3FzGZi2rcHw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,238,1716274800"; d="scan'208";a="57321350" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmviesa003.fm.intel.com with ESMTP; 25 Jul 2024 23:33:49 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 33142100567B; Fri, 26 Jul 2024 14:33:48 +0800 (CST) From: Haochen Jiang To: gcc-patches@gcc.gnu.org Cc: hongtao.liu@intel.com, ubizjak@gmail.com Subject: [PATCH] i386: Add non-optimize prefetchi intrins Date: Fri, 26 Jul 2024 14:33:48 +0800 Message-Id: <20240726063348.3859413-1-haochen.jiang@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP 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 Hi all, Under -O0, with the "newly" introduced intrins, the variable will be transformed as mem instead of the origin symbol_ref. The compiler will then treat the operand as invalid and turn the operation into nop, which is not expected. Use macro for non-optimize to keep the variable as symbol_ref just as how prefetch intrin does. Bootstrapped and regtested on x86-64-pc-linux-gnu. Ok for trunk and backport to GCC 14 and GCC 13? Thx, Haochen --- gcc/config/i386/prfchiintrin.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gcc/config/i386/prfchiintrin.h b/gcc/config/i386/prfchiintrin.h index dfca89c7d16..d6580e504c0 100644 --- a/gcc/config/i386/prfchiintrin.h +++ b/gcc/config/i386/prfchiintrin.h @@ -37,6 +37,7 @@ #define __DISABLE_PREFETCHI__ #endif /* __PREFETCHI__ */ +#ifdef __OPTIMIZE__ extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _m_prefetchit0 (void* __P) @@ -50,6 +51,14 @@ _m_prefetchit1 (void* __P) { __builtin_ia32_prefetchi (__P, 2); } +#else +#define _m_prefetchit0(P) \ + __builtin_ia32_prefetchi(P, 3); + +#define _m_prefetchit1(P) \ + __builtin_ia32_prefetchi(P, 2); + +#endif #ifdef __DISABLE_PREFETCHI__ #undef __DISABLE_PREFETCHI__