From patchwork Mon Nov 1 14:10:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 1549178 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=FfS67TRz; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HjZhP6vVpz9sS8 for ; Tue, 2 Nov 2021 01:11:16 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B562A3857C50 for ; Mon, 1 Nov 2021 14:11:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B562A3857C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635775873; bh=RiscasAkaJRGxnLmXDIikaQ7N3GR9VhuzasLuNSBmi4=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=FfS67TRzjnIsX5SAQzii+jT5eqpMnlkhVjWTDzufHIEK+OugxgnAR9COEZwUOCeeu XkxU8QF8O0RWSvDouHr8t9w1tbmoypvKpT9We6Rij8Z3bnvj/7fEPtdKeARPL8AJZ2 XxpRFPHDHCWXbmGJW0FORMTKOdBvOz6QGqsMEhyk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 4212E385840A for ; Mon, 1 Nov 2021 14:10:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4212E385840A Received: by mail-wm1-x331.google.com with SMTP id z200so12559065wmc.1 for ; Mon, 01 Nov 2021 07:10:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RiscasAkaJRGxnLmXDIikaQ7N3GR9VhuzasLuNSBmi4=; b=c8ye3W+Ofw9N63lj3eBJgqqljAU/qksiAosw+bbeY31EYbe1HGXU1btfY8cQH9Lk33 HElW3LE8XRySx4AmlA0Z//37giLJOaVKEB1eOkGzdUd9KhUmUe1170HKcfj9SuxUIL2l oHguXRnaG0Cm0JcRzZ5j/0WxFVBgdTQDJJI7Q9UgIZnOEP1/lgzllkMcYJhQEYpXq1qA kwZfFO0DirD+AfD6f7q9xr9U+iM+LI6n7W79VGuka12gi1+WsX6z/jjqDngdS8iz4pOH gXKPcmyTL4dKTNu1pUmPcJN5EHAHQmKlcVLbezUrTYgJ0fgXJoiLMqIpxkRn1KL+7IIl OaNw== X-Gm-Message-State: AOAM533WRpNui+jJGRXJuGPE1R/SCnBrt4eCNlQEjwGOU2ImFoU7HXHj 0NkF2i63U3m5bzpGKiPrCXs= X-Google-Smtp-Source: ABdhPJxczyxDNHmZg/vUDr3D7T+DldTV6i3Wt3vPWS3WCpDVj0Xes9ZXUEwMk2X6qgQh/nB3kAY7AA== X-Received: by 2002:a05:600c:1548:: with SMTP id f8mr39823761wmg.18.1635775831259; Mon, 01 Nov 2021 07:10:31 -0700 (PDT) Received: from nbbrfq (dynamic-2bq7di4u2lfl4qjka9-pd01.res.v6.highway.a1.net. [2001:871:227:33a8:f6a3:c58c:7641:e771]) by smtp.gmail.com with ESMTPSA id a4sm12049960wmb.39.2021.11.01.07.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 07:10:31 -0700 (PDT) Date: Mon, 1 Nov 2021 15:10:27 +0100 To: Aldy Hernandez Subject: redundant bitmap_bit_p followed by bitmap_clear_bit [was: Re: [COMMITTED] Kill second order relations in the path solver.] Message-ID: <20211101151027.06945d6a@nbbrfq> In-Reply-To: <20211028015530.6fd3ee60@nbbrfq> References: <20211027181323.395724-1-aldyh@redhat.com> <20211028015530.6fd3ee60@nbbrfq> MIME-Version: 1.0 X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Bernhard Reutner-Fischer via Gcc-patches From: Bernhard Reutner-Fischer Reply-To: Bernhard Reutner-Fischer Cc: rep.dot.nop@gmail.com, GCC patches Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" On Thu, 28 Oct 2021 01:55:30 +0200 Bernhard Reutner-Fischer wrote: > On Wed, 27 Oct 2021 20:13:21 +0200 > Aldy Hernandez via Gcc-patches wrote: > > @@ -1306,6 +1307,24 @@ path_oracle::killing_def (tree ssa) > > ptr->m_next = m_equiv.m_next; > > m_equiv.m_next = ptr; > > bitmap_ior_into (m_equiv.m_names, b); > > + > > + // Walk the relation list an remove SSA from any relations. > > s/an /and / > > > + if (!bitmap_bit_p (m_relations.m_names, v)) > > + return; > > + > > + bitmap_clear_bit (m_relations.m_names, v); > > IIRC bitmap_clear_bit returns true if the bit was set, false otherwise, > so should be used as if(!bitmap_clear_bit) above. > > + relation_chain **prev = &(m_relations.m_head); > > s/[()]// > thanks, There seems to be two other spots where a redundant bitmap_bit_p checks if we want to bitmap_clear_bit. In dse and ira. Like: $ cat ~/coccinelle/gcc_bitmap_bit_p-0.cocci ; echo EOF // replace redundant bitmap_bit_p() bitmap_clear_bit with the latter @ rule1 @ identifier fn; expression bitmap, bit; @@ fn(...) { <... ( -if (bitmap_bit_p (bitmap, bit)) +if (bitmap_clear_bit (bitmap, bit)) { ... - bitmap_clear_bit (bitmap, bit); ... } | -if (bitmap_bit_p (bitmap, bit)) +if (bitmap_clear_bit (bitmap, bit)) { ... } ... -bitmap_clear_bit (bitmap, bit); ) ...> } EOF $ find gcc/ -type f -a \( -name "*.c" -o -name "*.cc" \) -a \( ! -path "gcc/testsuite/*" -a ! -path "gcc/contrib/*" \) -exec spatch -sp_file ~/coccinelle/gcc_bitmap_bit_p-0.cocci --show-diff {} \; # in ira.c one would have to fixup the curly braces manually PS: coccinelle seems to ruin the spaces before braces in the '+' even though i have written them correctly according to GNU style.. diff = --- gcc/dse.c +++ /tmp/cocci-output-1104419-443759-dse.c @@ -3238,9 +3238,8 @@ mark_reachable_blocks (sbitmap unreachab edge e; edge_iterator ei; - if (bitmap_bit_p (unreachable_blocks, bb->index)) + if (bitmap_clear_bit(unreachable_blocks, bb->index)) { - bitmap_clear_bit (unreachable_blocks, bb->index); FOR_EACH_EDGE (e, ei, bb->preds) { mark_reachable_blocks (unreachable_blocks, e->src); diff = --- gcc/ira.c +++ /tmp/cocci-output-1104678-d8679a-ira.c @@ -2944,17 +2944,15 @@ mark_elimination (int from, int to) FOR_EACH_BB_FN (bb, cfun) { r = DF_LR_IN (bb); - if (bitmap_bit_p (r, from)) + if (bitmap_clear_bit(r, from)) { - bitmap_clear_bit (r, from); bitmap_set_bit (r, to); } if (! df_live) continue; r = DF_LIVE_IN (bb); - if (bitmap_bit_p (r, from)) + if (bitmap_clear_bit(r, from)) { - bitmap_clear_bit (r, from); bitmap_set_bit (r, to); } }