From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id 2A9973858D37 for ; Wed, 2 Mar 2022 19:32:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2A9973858D37 Received: by mail-pj1-x102c.google.com with SMTP id g7-20020a17090a708700b001bb78857ccdso5698339pjk.1 for ; Wed, 02 Mar 2022 11:32:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=hnGx1zI9CyTTdAz/C1TM9DYd5ws9OeTFKDJllSNcbHM=; b=4xMQeXwd939VghXxSsL7t1nG5+wh2SFrVT0DHRfvYRG6aUFKVCf7S6M0OmJPEJYl7c caYsC7YS+87fg2DNTnPmXm8Td2S4wWxS9m+M/T97VKM8vP3MD104a9zOEcqKT+RCjp60 QMxjRN0BM4rBGo6jPtEiW1/QgNbxjuQIQBBF3UJx6KppjPblVwZMHGc3RFREoECwzqpF UJzP9iS1FH6qowi0ZspsRAwMsDRs13HzK/TGX/mn8Kr0bKxzs65XiWnad9TivovPZqfe U9kZJmxVL2ysHT3h2rEHI4UPJUtV1wD5BO6FrSHpBpQbWTYnhXQKCukP/RlnzlBWmrZM 7Tfw== X-Gm-Message-State: AOAM533SBzjZS7beWjnwC8ffUnon3Oi+ds/b5zHaAx7xSBkKFjtGErfg sIznSQMkdbRyv5DPQocRoUg= X-Google-Smtp-Source: ABdhPJzbftNSKqEQ/pKY52I9UbuvlgYwE64RrQ+2aZXk6KAW6NrzGs2ExIYUG+hxLhOf3f6KPsqKbA== X-Received: by 2002:a17:902:9a47:b0:150:27e0:abc5 with SMTP id x7-20020a1709029a4700b0015027e0abc5mr27925196plv.109.1646249569106; Wed, 02 Mar 2022 11:32:49 -0800 (PST) Received: from [172.31.0.204] (c-73-63-24-84.hsd1.ut.comcast.net. [73.63.24.84]) by smtp.gmail.com with ESMTPSA id c9-20020a634e09000000b003790829fbc1sm3042757pgb.53.2022.03.02.11.32.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Mar 2022 11:32:48 -0800 (PST) Message-ID: <7da496e6-ee9b-e6ae-f4ed-dbadeef694ed@gmail.com> Date: Wed, 2 Mar 2022 12:32:47 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] PR tree-optimization/83907: Improved memset handling in strlen pass. Content-Language: en-US To: Roger Sayle , gcc-patches@gcc.gnu.org References: <014201d8267a$206e1320$614a3960$@nextmovesoftware.com> From: Jeff Law In-Reply-To: <014201d8267a$206e1320$614a3960$@nextmovesoftware.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.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, SCC_BODY_URI_ONLY, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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: Wed, 02 Mar 2022 19:32:51 -0000 On 2/20/2022 9:51 AM, Roger Sayle wrote: > This patch implements the missed optimization enhancement PR 83907, > by handling memset with a constant byte value in tree-ssa's strlen > optimization pass. Effectively, this treats memset(dst,'x',3) as > it would memcpy(dst,"xxx",3). > > This patch also includes a tweak to handle_store to address another > missed optimization observed in the related test case pr83907-2.c. > The consecutive byte stores to memory get coalesced into a vector > write of a vector const, but unfortunately tree-ssa-strlen's > handle_store didn't previously handle the (unusual) case where the > stored "string" starts with a zero byte but also contains non-zero > bytes. > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check with no new failures. Ok for mainline? > > > 2022-02-20 Roger Sayle > > gcc/ChangeLog > PR tree-optimization/83907 > * tree-ssa-strlen.cc (handle_builtin_memset): Record a strinfo > for memset with an constant char value. > (handle_store): Improved handling of stores with a first byte > of zero, but not storing_all_zeros_p. > > gcc/testsuite/ChangeLog > PR tree-optimization/83907 > * gcc.dg/tree-ssa/pr83907-1.c: New test case. > * gcc.dg/tree-ssa/pr83907-2.c: New test case. Deferring to stage1. jeff