From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28533 invoked by alias); 7 Oct 2016 11:01:17 -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 27998 invoked by uid 89); 7 Oct 2016 11:01:16 -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=HX-Envelope-From:sk:richard, Ready X-HELO: mail-wm0-f68.google.com Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Oct 2016 11:01:06 +0000 Received: by mail-wm0-f68.google.com with SMTP id i130so2395037wmg.0 for ; Fri, 07 Oct 2016 04:01:06 -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:content-transfer-encoding; bh=1QxkVCTNcNcoC0sQV5JPDAYcjFL0J9uOFlIGnc/cBcQ=; b=TqzgYzSyv8vOMQPKi59irgVO6xdarm3nTCsB6ZOrWGjJmL0Aeq8Wq3y2W5IcCuAqOJ wiZyRrkmNXyq0yG3J+Z/Uk5N5KIC65jnKDkK5zh+7I9uyLDtoTe/9pWEU9o+SBTA2AHd dKphjwQvVkA8/cKw95Y5bh2mfNcafV+aBA67lZ0ejZXyVgEeAZoDT9e3NYecf9At6nhu ulf2aBodTvdh6cLIWmCfFLOJ1v4IW6LNT09Au4k6QJx2IEeM80DMPtKbEuDv2JkKMT96 vHJ9AAt9F+v/eQNpvgRKCV9WboCRfnUneRKCqWhCR3H6ncg3uQwPkmcbIWNA1TvTXVkA nmJA== X-Gm-Message-State: AA6/9RllC/NC6ulD8aihoNCh0CrKKALaXLY3jsnauGExglHrjmmFTZgg8wc02q8u7X34N61scEZx99G6r6PVhQ== X-Received: by 10.28.19.134 with SMTP id 128mr19474111wmt.40.1475838064283; Fri, 07 Oct 2016 04:01:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.155.146 with HTTP; Fri, 7 Oct 2016 04:01:03 -0700 (PDT) In-Reply-To: <7c8c5c76-ba33-8fe5-5368-6741d39c8f83@suse.cz> References: <2f0f974b776ee917d094b78cd9b77b992988499c.1471416736.git.mliska@suse.cz> <7c8c5c76-ba33-8fe5-5368-6741d39c8f83@suse.cz> From: Richard Biener Date: Fri, 07 Oct 2016 11:01:00 -0000 Message-ID: Subject: Re: [PATCH 2/3] Fold __builtin_memchr (version 2) To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: GCC Patches Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00469.txt.bz2 On Fri, Oct 7, 2016 at 10:41 AM, Martin Li=C5=A1ka wrote: > Resending the patch, where I implemented folding in gimple-fold.c > > Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. +/* Fold a call to the str{n}{case}cmp builtin pointed by GSI iterator. + FCODE is the name of the builtin. */ wrong comment +static bool +gimple_fold_builtin_memchr (gimple_stmt_iterator *gsi) + { + replace_call_with_value (gsi, build_int_cst (type, 0)); use ptr_type_node (void *) instead of type here and below. + HOST_WIDE_INT offset =3D r - p1; + if (compare_tree_int (len, offset) <=3D 0) + { =3D=3D 0 can occur in which case we have to return a pointer to the first char. I think len < offset can't happen with memchr? + replace_call_with_value (gsi, build_int_cst (type, 0)); + return true; + } + else + { + tree temp =3D fold_build_pointer_plus_hwi_loc (loc, arg1, off= set); + replace_call_with_value (gsi, temp); That yields valid GIMPLE by chance, I'd prefer if you'd built that to a stmt and use the replace-with-vops. + return true; + } > Ready to be installed? > Martin