From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 From: Bernhard Reutner-Fischer To: Aldy Hernandez Cc: rep.dot.nop@gmail.com, Andrew MacLeod , GCC patches 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 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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-List-Received-Date: Mon, 01 Nov 2021 14:10:33 -0000 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 {} \; 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); } } # 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..