From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id 455ED385841F for ; Sat, 1 Oct 2022 19:03:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 455ED385841F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1036.google.com with SMTP id 8-20020a17090a0b8800b00205d8564b11so6874557pjr.5 for ; Sat, 01 Oct 2022 12:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=YKqzQjAKDCEdtYHmLvL4qq0KOuUhc4zc4I0zjnfxxNw=; b=FVlP+Ni0plod/3e1fcvDpUhTfc1LMI3MEo7HTnDKJOsE4ji+NkGXuaO5YEpsSZGYcM STLweiikXZYrHPAJR5rl8R5O6FC6zpd8kV5fXNkkpA79l6L9yusSlk0Rs3RmbjFzODkZ MN61Jugfe2qu9VyNfrWuCi+3yGoTi9v6plvj7Meo43h208zhJNlRjmcPv805xnlc5GZw MYB0evbSy8r4Ki5h601h1yDQEy12eMYAHlE7I79reaUnaw6ixga+WvQhbRgp1aZKB6mp A51Zcwt8LshEdZhmNDTcMQuaB6tRVlYr3umBbjdpe/KOQ37lH/Mt7biHI4JETIYjxNRB V8pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=YKqzQjAKDCEdtYHmLvL4qq0KOuUhc4zc4I0zjnfxxNw=; b=LM+lzYN9tVb/IT+X7+5+fA7xLwZHG8OdMZf7vZl0oxhlv0P80yJbr6ds77YmP9chqm e3GqbJlSJi95Aa46cndcbIEKPNgwN140RijpkFLbeBFa2ovx0MZay57ImalHu5v2SYqG PzcrlwN3gLvOUA+7BtuwaGgp8r8bXW7DREBUrMzN3DGAo2kM3d5mQLZt9vigxA9ZdFw3 lcTFy1Z95Yw37DUpmvmM3T66N+xYFqUnhUcAE4g2tje/goiPTMaviJ9dMlr7wFHlVqyi 7TMhR2n6kqwpZMuhVU+GTDsVX5qEjYjk10RSXmtYKwKw0ij8CBo7NeSWN82er+y9F5x1 HCEg== X-Gm-Message-State: ACrzQf3tL9JXKKCFa4UH28qkvQ0bW4n6DBi9x3YJ3/P0uzivEnFXT+ys gz7bO3JEDgmscRLZjxa60+/1W4MAlOeIfw== X-Google-Smtp-Source: AMsMyM6qdpbFTY71TBNjilvfX34bne8yDHslXTTVTK05Su50AtiejVj7oe9qmqY6CGMaIgHnexYxdw== X-Received: by 2002:a17:90b:3a8a:b0:20a:7e68:91a with SMTP id om10-20020a17090b3a8a00b0020a7e68091amr1798320pjb.206.1664650995737; Sat, 01 Oct 2022 12:03:15 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id f6-20020aa79d86000000b0053e2b61b714sm357927pfq.114.2022.10.01.12.03.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 01 Oct 2022 12:03:15 -0700 (PDT) Message-ID: Date: Sat, 1 Oct 2022 13:03:14 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [RFA] Avoid unnecessary load-immediate in coremark Content-Language: en-US To: gcc-patches@gcc.gnu.org References: From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,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: On 9/30/22 04:47, Richard Sandiford wrote: > Jeff Law writes: >> This is another minor improvement to coremark.   I suspect this only >> improves code size as the load-immediate was likely issuing with the ret >> statement on multi-issue machines. >> >> >> Basically we're failing to utilize conditional equivalences during the >> post-reload CSE pass.  So if a particular block is only reached when a >> certain condition holds (say for example a4 == 0) and the block has an >> assignment like a4 = 0, we would fail to eliminate the unnecessary >> assignment. > I wasn't sure (and was too lazy to try, sorry), but: is the reason > that we fail to catch this earlier because the two uses of r4 are > entirely separate (i.e. not from the same pseudo)? Right.  Different pseudos used in the comparison vs the destination of the assignment.  If they used the same pseudo, then I would have expected cse or gcse to pick it up. > >> + /* Iterate over each incoming edge and see if they >> + all have the same implicit set. */ >> + FOR_EACH_EDGE (e, ei, bb->preds) >> + { >> + /* If the predecessor does not end in a conditional >> + jump, then it does not have an implicit set. */ >> + if (e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun) >> + && !block_ends_with_condjump_p (e->src)) >> + { >> + found = false; >> + break; >> + } >> + >> + /* We know the predecessor ends with a conditional >> + jump. Now dig into the actal form of the jump >> + to potentially extract an implicit set. */ > Very minor, but it looked odd to fall through for the entry block. > How about: > > if (e->src == ENTRY_BLOCK_PTR_FOR_FN (cfun) > || !block_ends_with_condjump_p (e->src)) > > ? Looks like a mistake to me.  we don't want to process anything for a successor of the entry block.  I'll adjust and retest. Thanks, Jeff