From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from brown.birch.relay.mailchannels.net (brown.birch.relay.mailchannels.net [23.83.209.23]) by sourceware.org (Postfix) with ESMTPS id 89CB23858405 for ; Mon, 15 Nov 2021 17:34:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 89CB23858405 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A68559224A0; Mon, 15 Nov 2021 17:34:08 +0000 (UTC) Received: from pdx1-sub0-mail-a307.dreamhost.com (100-96-17-73.trex.outbound.svc.cluster.local [100.96.17.73]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 3058292245E; Mon, 15 Nov 2021 17:34:08 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a307.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.96.17.73 (trex/6.4.3); Mon, 15 Nov 2021 17:34:08 +0000 X-MC-Relay: Junk X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Shelf-Interest: 14ebaba86c2ced1c_1636997648425_1036255809 X-MC-Loop-Signature: 1636997648425:2574385580 X-MC-Ingress-Time: 1636997648424 Received: from rhbox.redhat.com (unknown [1.186.223.29]) (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) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a307.dreamhost.com (Postfix) with ESMTPSA id 4HtGWy3PLnz2P; Mon, 15 Nov 2021 09:34:05 -0800 (PST) From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Subject: [PATCH v2 0/3] gimple-fold improvements Date: Mon, 15 Nov 2021 23:03:12 +0530 Message-Id: <20211115173315.1857598-1-siddhesh@gotplt.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211111194116.1626980-1-siddhesh@gotplt.org> References: <20211111194116.1626980-1-siddhesh@gotplt.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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, 15 Nov 2021 17:34:12 -0000 This patchset improves folding in cases where input lengths and/or destination sizes may not be constant but are range bound. Tested on x86_64 with a full bootstrap build and verified that there are no regressions resulting from this patchset. I double-checked that the run was current and I wasn't checking logs of a stale build. I tested builds of bash and wpa_supplicant with this patchset. wpa_supplicant ends up with 30 fewer __memcpy_chk calls, of which 14 are completely optimized away and the rest transformed to __memcpy. In bash, 3 __memcpy_chk calls are optimized away completely in addition to a couple of memmove and strcpy chk variants being transformed into regular calls. Changes from v1: - Use dump_* functions instead of directly using dump_file - Bring back warnings and reduce scope of changes to strncat to only using ranges to determine if call can be simplified to strcat. - Renamed known_safe to known_lower Siddhesh Poyarekar (3): gimple-fold: Transform stp*cpy_chk to str*cpy directly gimple-fold: Use ranges to simplify _chk calls gimple-fold: Use ranges to simplify strncat and snprintf gcc/gimple-fold.c | 343 ++++++++++-------------- gcc/testsuite/gcc.dg/Wobjsize-1.c | 5 +- gcc/testsuite/gcc.dg/fold-stringops-1.c | 23 ++ gcc/testsuite/gcc.dg/fold-stringops-2.c | 63 +++++ gcc/testsuite/gcc.dg/fold-stringops-3.c | 18 ++ 5 files changed, 256 insertions(+), 196 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/fold-stringops-1.c create mode 100644 gcc/testsuite/gcc.dg/fold-stringops-2.c create mode 100644 gcc/testsuite/gcc.dg/fold-stringops-3.c -- 2.31.1