From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 0F6EE3858414 for ; Thu, 9 Feb 2023 14:24:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F6EE3858414 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id F37343758C for ; Thu, 9 Feb 2023 14:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1675952681; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=h4+YxqSPQRMfnpVoLGq6BAwwVyLvLFdsmMugAz3O040=; b=XrmhwB5OHryWDWye7mXifDXWfgjBEd1UsOKuLZv2cK+rbFadei4oKJE3191kRYhhV3Dtzw y33ZVnS+vF1bHvJH3K3oXeFCo8X2RsBV8UCrvGKSIYkFEbNYCkVIj2v0+18kQcj6c1r6nj Yd2kWzAllpc2LbBqtOcXehfNU2Ibd2Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1675952681; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=h4+YxqSPQRMfnpVoLGq6BAwwVyLvLFdsmMugAz3O040=; b=0DDI5pSlnRPAKKeXNYCTenV4xuHrfRQCBpCJPjv0y8st0Hok2nzcChrmZd2fT1Gau9CkLe imKvre3E/DqAojCA== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id EA5372C141 for ; Thu, 9 Feb 2023 14:24:40 +0000 (UTC) Date: Thu, 9 Feb 2023 14:24:40 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] target/108738 - optimize bit operations in STV User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,MISSING_MID,SPF_HELO_NONE,SPF_PASS,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 List-Id: Message-ID: <20230209142440.OLrdX31_cR8Y3XSoIL2Th9BIqvkPb8GaCd7queE0ro0@z> The following does low-hanging optimizations, combining bitmap test and set and removing redundant operations. This shaves off half of the testcase compile time. Bootstrapped and tested on x86_64-unknown-linux-gnu, OK? Thanks, Richard. PR target/108738 * config/i386/i386-features.cc (scalar_chain::add_to_queue): Combine bitmap test and set. (scalar_chain::add_insn): Likewise. (scalar_chain::analyze_register_chain): Remove redundant attempt to add to queue and instead strengthen assert. Sink common attempts to mark the def dual-mode. (scalar_chain::add_to_queue): Remove redundant insn bitmap check. --- gcc/config/i386/i386-features.cc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc index 9bd6d8677bb..eff91301009 100644 --- a/gcc/config/i386/i386-features.cc +++ b/gcc/config/i386/i386-features.cc @@ -314,14 +314,12 @@ scalar_chain::~scalar_chain () void scalar_chain::add_to_queue (unsigned insn_uid) { - if (bitmap_bit_p (insns, insn_uid) - || bitmap_bit_p (queue, insn_uid)) + if (!bitmap_set_bit (queue, insn_uid)) return; if (dump_file) fprintf (dump_file, " Adding insn %d into chain's #%d queue\n", insn_uid, chain_id); - bitmap_set_bit (queue, insn_uid); } /* For DImode conversion, mark register defined by DEF as requiring @@ -362,10 +360,9 @@ void scalar_chain::analyze_register_chain (bitmap candidates, df_ref ref) { df_link *chain; + bool mark_def = false; - gcc_assert (bitmap_bit_p (insns, DF_REF_INSN_UID (ref)) - || bitmap_bit_p (candidates, DF_REF_INSN_UID (ref))); - add_to_queue (DF_REF_INSN_UID (ref)); + gcc_checking_assert (bitmap_bit_p (insns, DF_REF_INSN_UID (ref))); for (chain = DF_REF_CHAIN (ref); chain; chain = chain->next) { @@ -398,9 +395,12 @@ scalar_chain::analyze_register_chain (bitmap candidates, df_ref ref) if (dump_file) fprintf (dump_file, " r%d use in insn %d isn't convertible\n", DF_REF_REGNO (chain->ref), uid); - mark_dual_mode_def (ref); + mark_def = true; } } + + if (mark_def) + mark_dual_mode_def (ref); } /* Add instruction into a chain. */ @@ -408,14 +408,12 @@ scalar_chain::analyze_register_chain (bitmap candidates, df_ref ref) void scalar_chain::add_insn (bitmap candidates, unsigned int insn_uid) { - if (bitmap_bit_p (insns, insn_uid)) + if (!bitmap_set_bit (insns, insn_uid)) return; if (dump_file) fprintf (dump_file, " Adding insn %d to chain #%d\n", insn_uid, chain_id); - bitmap_set_bit (insns, insn_uid); - rtx_insn *insn = DF_INSN_UID_GET (insn_uid)->insn; rtx def_set = single_set (insn); if (def_set && REG_P (SET_DEST (def_set)) -- 2.35.3