From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27285 invoked by alias); 29 Sep 2016 08:31:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 27261 invoked by uid 89); 29 Sep 2016 08:31:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=sk:wilco.d, wilcodijkstraarmcom, WilcoDijkstraarmcom, sk:wilcod X-HELO: mail-wm0-f66.google.com Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Sep 2016 08:31:20 +0000 Received: by mail-wm0-f66.google.com with SMTP id w72so893947wmf.1 for ; Thu, 29 Sep 2016 01:31:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=wFyAdPG2R9EUD0YZ9v8HzDg+2ndqZkDd/t6Blbsp+XI=; b=LWmhAW+CD+MGdSS+6BMzJBc/c9QqMtTRIOThpILtlbuZktXvC7mP1uGd269VQ184Il syDhzNO7TqA+lfBrmWyDbdfgLK5BLPw2zD4G4ssCiZHWl+RKe6N6EQvzMO9+AOAbm410 L5RIJtM8mZyx8PFHsUI3QbY4QQi8yTX/nEVXaZZ6IRsmEB6GaWo+8/ah49rnPMX3XBkC h7r2NU2efT3M81BvJo5Y7LtVylkqiH+1IO6u1py3my5loFF2WeVW+Qcyv89i0vt4i89Z +9aPfqTsIuhyp7QrzsekKEMi808GodjCJhtpXS9LvTQHJElC2uBC3mYQjyiuwza79Z3X rdpg== X-Gm-Message-State: AA6/9RnYCV5xXQF3IPsD/poa1SEHBhUSbX8vdyrMr0BdqSYTIv2LTd3amNKIu+ac1KelEKukv+HjsW4QGHwxyQ== X-Received: by 10.28.56.198 with SMTP id f189mr12611864wma.129.1475137878534; Thu, 29 Sep 2016 01:31:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.155.210 with HTTP; Thu, 29 Sep 2016 01:31:17 -0700 (PDT) In-Reply-To: References: <1474639855.2578.2.camel@t-online.de> From: Richard Biener Date: Thu, 29 Sep 2016 08:46:00 -0000 Message-ID: Subject: Re: [PATCH v3] Optimize strchr to strlen To: Jason Merrill Cc: Wilco Dijkstra , GCC Patches , nd Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-09/txt/msg02218.txt.bz2 On Wed, Sep 28, 2016 at 5:45 PM, Jason Merrill wrote: > OK. > > On Wed, Sep 28, 2016 at 11:43 AM, Wilco Dijkstra wrote: >> Jason Merrill wrote: >>> I think this broke g++.dg/ext/builtin10.C. >> >> That's odd. It appears if you add a fold in gimple-fold.c, it no longer calls the >> folding code in builtins.c. No idea what the idea behind that is (especially since >> there are other builtins that appear in both files), but this simple patch fixes it: >> >> If strchr can't be folded in gimple-fold.c, break so folding code in builtins.c is >> also called. >> >> OK for commit? Please move the remaining folding of strchr to gimple-fold.c then. All of the non-constant "folding" in builtins.c should move there, constant folding parts should move to fold-const-call.c. Thanks, Richard. >> 2016-09-28 Wilco Dijkstra >> >> * gimple-fold.c (gimple_fold_builtin): After failing to fold >> strchr, also try the generic folding. >> -- >> diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c >> index ddf4cf0ae68ef6708377fdb1a2b45575d90da799..b6802e81fd1a7fd0b309cb9aa0f984f7bacb6596 100644 >> --- a/gcc/gimple-fold.c >> +++ b/gcc/gimple-fold.c >> @@ -2948,7 +2948,10 @@ gimple_fold_builtin (gimple_stmt_iterator *gsi) >> case BUILT_IN_STRNCAT: >> return gimple_fold_builtin_strncat (gsi); >> case BUILT_IN_STRCHR: >> - return gimple_fold_builtin_strchr (gsi); >> + if (gimple_fold_builtin_strchr (gsi)) >> + return true; >> + /* Perform additional folding in builtin.c. */ >> + break; >> case BUILT_IN_FPUTS: >> return gimple_fold_builtin_fputs (gsi, gimple_call_arg (stmt, 0), >> gimple_call_arg (stmt, 1), false); >>