From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2063) id EC3733858D32; Mon, 16 Oct 2023 02:07:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC3733858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697422040; bh=a6sjwv3j004Ih4Kk+Bz/kcbjbTVM+rjyLG1KfC9oe80=; h=From:To:Subject:Date:From; b=sOgxY5VgQSt9sb13DSClm2aRa4qksIF+EIjhWcl91yC7f/qGGa7YODSA5P8kA9XxR rr4AYYCODe/xdE89Eh24F66nG2/YzjkCjEenCTDy8RT9MuhFuSYbdilkNNGzSLEzZV 3HSHXMHpF8LJcX2+ZB193kziBBJMPORhwwGWQv50= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Kewen Lin To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-7953] rs6000: Skip empty inline asm in rs6000_update_ipa_fn_target_info [PR111366] X-Act-Checkin: gcc X-Git-Author: Kewen Lin X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: 8ae7823fba8f975c0bb886736553c20ca7dbfab2 X-Git-Newrev: 4d22de945430e6f8c33ef98c90a4fad8de0ef41e Message-Id: <20231016020720.EC3733858D32@sourceware.org> Date: Mon, 16 Oct 2023 02:07:20 +0000 (GMT) List-Id: https://gcc.gnu.org/g:4d22de945430e6f8c33ef98c90a4fad8de0ef41e commit r13-7953-g4d22de945430e6f8c33ef98c90a4fad8de0ef41e Author: Kewen Lin Date: Sun Oct 15 21:05:40 2023 -0500 rs6000: Skip empty inline asm in rs6000_update_ipa_fn_target_info [PR111366] PR111366 exposes one thing that can be improved in function rs6000_update_ipa_fn_target_info is to skip the given empty inline asm string, since it's impossible to adopt any hardware features (so far HTM). Since this rs6000_update_ipa_fn_target_info related approach exists in GCC12 and later, the affected project highway has updated its target pragma with ",htm", see the link: https://github.com/google/highway/commit/15e63d61eb535f478bc I'd not bother to consider an inline asm parser for now but will file a separated PR for further enhancement. PR target/111366 gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_update_ipa_fn_target_info): Skip empty inline asm. gcc/testsuite/ChangeLog: * g++.target/powerpc/pr111366.C: New test. (cherry picked from commit a65b38e361320e0aa45adbc969c704385ab1f45b) Diff: --- gcc/config/rs6000/rs6000.cc | 9 ++++-- gcc/testsuite/g++.target/powerpc/pr111366.C | 48 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 1e4f319f4cd..3854cab9092 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -25415,9 +25415,12 @@ rs6000_update_ipa_fn_target_info (unsigned int &info, const gimple *stmt) /* Assume inline asm can use any instruction features. */ if (gimple_code (stmt) == GIMPLE_ASM) { - /* Should set any bits we concerned, for now OPTION_MASK_HTM is - the only bit we care about. */ - info |= RS6000_FN_TARGET_INFO_HTM; + const char *asm_str = gimple_asm_string (as_a (stmt)); + /* Ignore empty inline asm string. */ + if (strlen (asm_str) > 0) + /* Should set any bits we concerned, for now OPTION_MASK_HTM is + the only bit we care about. */ + info |= RS6000_FN_TARGET_INFO_HTM; return false; } else if (gimple_code (stmt) == GIMPLE_CALL) diff --git a/gcc/testsuite/g++.target/powerpc/pr111366.C b/gcc/testsuite/g++.target/powerpc/pr111366.C new file mode 100644 index 00000000000..6d3d8ebc552 --- /dev/null +++ b/gcc/testsuite/g++.target/powerpc/pr111366.C @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* Use -Wno-attributes to suppress the possible warning on always_inline. */ +/* { dg-options "-O2 -mdejagnu-cpu=power9 -Wno-attributes" } */ + +/* Verify it doesn't emit any error messages. */ + +#include +#define HWY_PRAGMA(tokens) _Pragma (#tokens) +#define HWY_PUSH_ATTRIBUTES(targets_str) HWY_PRAGMA (GCC target targets_str) +__attribute__ ((always_inline)) void +PreventElision () +{ + asm(""); +} +#define HWY_BEFORE_NAMESPACE() HWY_PUSH_ATTRIBUTES (",cpu=power10") +HWY_BEFORE_NAMESPACE () namespace detail +{ + template struct CappedTagChecker + { + }; +} +template +using CappedTag = detail::CappedTagChecker; +template struct ForeachCappedR +{ + static void Do (size_t, size_t) + { + CappedTag d; + Test () (int(), d); + } +}; +template struct ForPartialVectors +{ + template void operator() (T) + { + ForeachCappedR::Do (1, 1); + } +}; +struct TestFloorLog2 +{ + template void operator() (T, DF) { PreventElision (); } +}; +void +TestAllFloorLog2 () +{ + ForPartialVectors () (float()); +} +