From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26812 invoked by alias); 4 May 2014 16:59:43 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 26777 invoked by uid 48); 4 May 2014 16:59:40 -0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/61056] strchr (x, 0) is not converted to strlen (x) Date: Sun, 04 May 2014 16:59:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: olegendo at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-05/txt/msg00207.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61056 --- Comment #2 from Oleg Endo --- (In reply to Jakub Jelinek from comment #1) > 1) your testcase uses strrchr rather than strchr Sorry, typo/pasto. It was meant to be "strchr". > 2) why do you think it is desirable to convert strchr (x, 0) to x + strlen > (x)? On SH we have a builtin strlen implementation. I was just expecting strchr (x, 0) to utilize it, that's all. > Unless you have good library implementation for the latter and bad for the > former, strchr (x, 0) should be a win. > What the strlen pass does is that if you e.g. use strchr (x, 0) or strlen > (x) several times when the lengths of the strings actually can't change in > between, it can avoid the second and following call. And, it is able to > deal even with strlen (x) used in one place and strchr (x, 0) in another or > vice versa etc. (plus various other optimizations). Ah, thanks for the explanation. BTW, are there any plans to add true builtin strchr support so that it can be expanded by the target code in the same way as strlen?