From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by sourceware.org (Postfix) with ESMTPS id 63FBD385737E for ; Thu, 12 May 2022 15:27:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 63FBD385737E Received: by mail-pj1-x102f.google.com with SMTP id x88so5509749pjj.1 for ; Thu, 12 May 2022 08:27:48 -0700 (PDT) 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=K7ED/z+R90PY0k2EihWNOcD6Hwnznzso3zMxObkMfTA=; b=tfQQAAlrlaTowhXfcTIUI2IN0TCATjClbFAjb79JxMhQ1FejL1iAUtEu2WLytXgV0/ Kr1pVE5S71+3F6yUS64+X8ykB6m3xTex9GmEdCRGchZ3J78nTI35YjlGUW8FIcJ6vjhh KP8DtF9itJOWG+DUTOK8vEcDCozID82eNoCELFfErHuEk5jQ4yjxOMkCY2Gqj4Sr2xtm QihJSC9yjHzXZ4LkswnJU2CUaV1yDka+RW3Rhz/JpR9fxUbM1jo/F/vUlRU9hXYod9L8 hjcDpvDouqf1ZLsfvtWhQZIU/Wl9Dw7G2Paohxkj0T9dRLiBByDX47bH6kb2dVstkGgb cdfQ== X-Gm-Message-State: AOAM532USbko1VvDtwn9EqBtwwWHahXSrT93ci3gbPJsz9UiAk+MNU1i A00SoOJuZkhwTFnvbAD/trSml2MWOXc= X-Google-Smtp-Source: ABdhPJzj9HT1RnfKHyCiHk3V05gOADVMuCH+C0AZ6oSx1XPWIb5M+S++6uP8TxT+us79ouCMe4KNWg== X-Received: by 2002:a17:902:f70c:b0:14e:f1a4:d894 with SMTP id h12-20020a170902f70c00b0014ef1a4d894mr453069plo.65.1652369266987; Thu, 12 May 2022 08:27:46 -0700 (PDT) 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 e11-20020a63370b000000b003c14af5061esm2067099pga.54.2022.05.12.08.27.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 May 2022 08:27:46 -0700 (PDT) Message-ID: Date: Thu, 12 May 2022 09:27:45 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH] PR tree-optimization/83907: Improved memset handling in strlen pass. Content-Language: en-US To: 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: 8bit 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, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Thu, 12 May 2022 15:27:49 -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. OK after a re-test.  Thanks for the ping. jeff