From patchwork Tue May 16 08:01:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 99851 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1899005qge; Tue, 16 May 2017 01:02:27 -0700 (PDT) X-Received: by 10.98.9.92 with SMTP id e89mr10730263pfd.177.1494921747410; Tue, 16 May 2017 01:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494921747; cv=none; d=google.com; s=arc-20160816; b=oa7NE2W+2UXtCEDr8SzJVLN8KLlM1FnstM+jhpnqS2f7euT4XbyfnOK4+keLGpa/WU 9jR0F+KOLjWf9rKpfTsm6sQ6bp9shfBM7mP/nE9N+zkiaBYl+JivuOCxWkUnWm2BIjmt VHiApPQpF69eRQuy6XDw1QR8MZck39/STHvEsb79378kgPPHhbi2gybSU5bTE8FZKBQV VwrHbaW+cw4zwrMGcR0X793F3RL5r6wDZ97o2BqaR3GnVyfLh7ucnI6rw7Fya52OwA+j orjZ80UfMaoxZNncF3Na4kJEuP75a00vPuOizz6F9BOw2/nsLyp45z5dQBgULRpg95R3 bKag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=oOx1xUIphW3yAFw+0vF36WLC4tqcjWkpbQwkSiaka1E=; b=mTXgp5ZuJM753zCl8LDUIk+YcJHoHOTjs3DQ0H+0qSxH3HbbQKjrTGj93x+l7OOmn5 MZ1rNm6uGG2YsUdOMhi2uTwBqID2FkoZ0b0Vdd4+xK13+tepmV5mbVSgREBb2D+H9abp qD5BhB+NRWDqiUWq6C4wFFbtCeyf2NRROcozL2Ppa/Dy9XOfxPwKCSUdZ5B/VO7pSp3N 0jKA62gcCfp/0fbZgUGd/HFaJWeddzXtnfgvX/Cur8eITe+Q25nOnbitPvNbQh7eZbkC 519q6yY2ThwaWPyQ5+dT0lG+/0vhj7s4OcqtjET0fl+8tijfUIbcQJpqSr++JzjIgWGy f+YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-453742-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-453742-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e185si12939604pfa.234.2017.05.16.01.02.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 May 2017 01:02:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-453742-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-453742-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-453742-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=fEHIpNf98yse2UyZtEUZ+lyeiuZHdlNJ4vNz3EN9RlUmO8F71RFI/ w4KRH9pe8GF8hm5R7ff0NVIOvtNVoMqtFB+oLLC7EVV6szuuxiNtcaN8PuhcON1u OadFeS0TbCyrT70iIDmKdw/P1eREfuLvNh3ZtPLJ+c3FSNjdFHhxn0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=UIamjeEqHNuN6PDxiksMckuDEI8=; b=W2yf84VMap+rcnqyN4nF ZX+1Ykml8d4hxsI4tGEmrXatgW2qeiEfklpMWrjf1KLwqKPc3l54ADqKNVtXh0Bs Q+o4P4KvOvn1Vbquit39VBInkQNiD2V/u7uoi9f2IzjED+YeTGzkYykX5ZtxQctf Ro46cE/5KlkwRBlVcSmItfI= Received: (qmail 119908 invoked by alias); 16 May 2017 08:02:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 119717 invoked by uid 89); 16 May 2017 08:02:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:threembb.co.uk, H*r:ip*05.16.01.01 X-HELO: mail-wm0-f51.google.com Received: from mail-wm0-f51.google.com (HELO mail-wm0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 May 2017 08:01:59 +0000 Received: by mail-wm0-f51.google.com with SMTP id u65so33607608wmu.1 for ; Tue, 16 May 2017 01:02:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=oOx1xUIphW3yAFw+0vF36WLC4tqcjWkpbQwkSiaka1E=; b=iCE8WfqZJMRAQ6KuJjYRrKZeQJ1NENSTPSnpFjBs1PYbSAdwHMkfMXU51rwQntpYmq trv8wtVcN54xvjXPWUzsWUtmmgFp6wPg7vfZbC2AZ0nRVHxw2fHSc+SMJ959hmm6XBlJ S9FS5CT3H5wZUmoNGuAox8oHdr8CKOuqTv1W9Gyj/+HKFL+v+ziYMYdQRMLzu32sgNk8 /4tU8JqBnECg/Smi+zpDKviaOmVarv/jsgPfZXOLRZ09+OJgi0HSzP3Y0GfDtqEPLQt3 W35sVe0c+qq6W+fq8PK8OK5TAPVIzUIJQEwOPvHg1DejMFYKPvuB02AYmipnm2C/erTs 91nA== X-Gm-Message-State: AODbwcD8aW10SlITA8wj8KWOHLwNtKeezGFRKhYxARnlsTVaccTSkF5k JTNQqqb3B89GUMdj/XZdjQ== X-Received: by 10.28.193.202 with SMTP id r193mr5655167wmf.31.1494921719923; Tue, 16 May 2017 01:01:59 -0700 (PDT) Received: from localhost (188.29.164.181.threembb.co.uk. [188.29.164.181]) by smtp.gmail.com with ESMTPSA id m191sm13376847wmg.30.2017.05.16.01.01.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 May 2017 01:01:59 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [1/2] Add get_next_strinfo helper function Date: Tue, 16 May 2017 09:01:57 +0100 Message-ID: <87inl1ut56.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 This patch just adds a helper function for getting the next strinfo in a chain, since part 2 adds another place where we do that. Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Thanks, Richard 2017-05-16 Richard Sandiford gcc/ * tree-ssa-strlen.c (get_next_strinfo): New function. (get_stridx_plus_constant): Use it. (zero_length_string): Likewise. (adjust_related_strinfos): Likewise. (adjust_last_stmt): Likewise. Index: gcc/tree-ssa-strlen.c =================================================================== --- gcc/tree-ssa-strlen.c 2017-05-15 19:57:18.899053381 +0100 +++ gcc/tree-ssa-strlen.c 2017-05-15 20:50:21.412511763 +0100 @@ -156,6 +156,19 @@ get_strinfo (int idx) return (*stridx_to_strinfo)[idx]; } +/* Get the next strinfo in the chain after SI, or null if none. */ + +static inline strinfo * +get_next_strinfo (strinfo *si) +{ + if (si->next == 0) + return NULL; + strinfo *nextsi = get_strinfo (si->next); + if (nextsi == NULL || nextsi->first != si->first || nextsi->prev != si->idx) + return NULL; + return nextsi; +} + /* Helper function for get_stridx. */ static int @@ -665,10 +678,8 @@ get_stridx_plus_constant (strinfo *bases gcc_checking_assert (compare_tree_int (si->length, off) != -1); for (chainsi = si; chainsi->next; chainsi = si) { - si = get_strinfo (chainsi->next); + si = get_next_strinfo (chainsi); if (si == NULL - || si->first != chainsi->first - || si->prev != chainsi->idx || si->length == NULL_TREE || TREE_CODE (si->length) != INTEGER_CST) break; @@ -736,26 +747,18 @@ zero_length_string (tree ptr, strinfo *c si = verify_related_strinfos (chainsi); if (si) { - chainsi = si; - for (; chainsi->next; chainsi = si) + do { - if (chainsi->endptr == NULL_TREE) + gcc_assert (si->length || si->stmt); + if (si->endptr == NULL_TREE) { - chainsi = unshare_strinfo (chainsi); - chainsi->endptr = ptr; + si = unshare_strinfo (si); + si->endptr = ptr; } - si = get_strinfo (chainsi->next); - if (si == NULL - || si->first != chainsi->first - || si->prev != chainsi->idx) - break; - } - gcc_assert (chainsi->length || chainsi->stmt); - if (chainsi->endptr == NULL_TREE) - { - chainsi = unshare_strinfo (chainsi); - chainsi->endptr = ptr; + chainsi = si; + si = get_next_strinfo (si); } + while (si != NULL); if (chainsi->length && integer_zerop (chainsi->length)) { if (chainsi->next) @@ -833,12 +836,8 @@ adjust_related_strinfos (location_t loc, si->endptr = NULL_TREE; si->dont_invalidate = true; } - if (si->next == 0) - return; - nsi = get_strinfo (si->next); - if (nsi == NULL - || nsi->first != si->first - || nsi->prev != si->idx) + nsi = get_next_strinfo (si); + if (nsi == NULL) return; si = nsi; } @@ -995,15 +994,9 @@ adjust_last_stmt (strinfo *si, gimple *s return; while (firstsi != lastsi) { - strinfo *nextsi; - if (firstsi->next == 0) - return; - nextsi = get_strinfo (firstsi->next); - if (nextsi == NULL - || nextsi->prev != firstsi->idx - || nextsi->first != si->first) + firstsi = get_next_strinfo (firstsi); + if (firstsi == NULL) return; - firstsi = nextsi; } }