From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77189 invoked by alias); 28 Mar 2017 12:34:09 -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 77172 invoked by uid 89); 28 Mar 2017 12:34:08 -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=BinChengarmcom, Bin.Cheng@arm.com, goal, sk:BinChe X-HELO: mail-ot0-f177.google.com Received: from mail-ot0-f177.google.com (HELO mail-ot0-f177.google.com) (74.125.82.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Mar 2017 12:34:06 +0000 Received: by mail-ot0-f177.google.com with SMTP id y88so50605778ota.2 for ; Tue, 28 Mar 2017 05:34:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=hwh/xPZABGtU6kz+7U3Ec5fYX+BlyQMF6rbCMiG761Q=; b=DGV7iKORxcTPwO89Y+hoKONoToqClsYxo2+QfNqgFXQlMtIMPlLfyHLlunWd2Un69S 43qZxweTc7Me7w2JQOCDHerq2+hl+NNp75h9rMUpJ6sf/IqpmVT+xN0iXCvJezjuncsa LUFqJJN3lG9I8Zf+WZipcR0U4NbAnKofjGR7Ulfj7EAQiDVqqUVlrJJRHrEHXEobdlC2 QfmRclRXmEbIxaFKe+J2nWQvK8NiLYD7xojxuyiyniMmaoRk60kVfJ9ywdL5eB9JKlNs z5VrrJJT+cTziAIaLMSyXrpjbvXacizv3CLTe+Y+IGLQKZM0cBDSmevl0ujZDqXuNxBf 7ivw== X-Gm-Message-State: AFeK/H1vRykpqefOg3Yf57en2cTudIK5w/mOVBgqUFqd6u4L9I9PSJB1t4iatr/Wzk2xCB9u2/36/oPsG+q0aw== X-Received: by 10.157.23.25 with SMTP id i25mr8506757ota.175.1490704446530; Tue, 28 Mar 2017 05:34:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.83.4 with HTTP; Tue, 28 Mar 2017 05:34:06 -0700 (PDT) In-Reply-To: References: From: Richard Biener Date: Tue, 28 Mar 2017 12:39:00 -0000 Message-ID: Subject: Re: [PATCH PR80153]Always generate folded type conversion in tree-affine To: Bin Cheng Cc: "gcc-patches@gcc.gnu.org" , nd Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg01446.txt.bz2 On Tue, Mar 28, 2017 at 2:01 PM, Bin Cheng wrote: > Hi, > This patch is to fix PR80153. As analyzed in the PR, root cause is tree_affine lacks > ability differentiating (unsigned)(ptr + offset) and (unsigned)ptr + (unsigned)offset, > even worse, it always returns the former expression in aff_combination_tree, which > is wrong if the original expression has the latter form. The patch resolves the issue > by always returning the latter form expression, i.e, always trying to generate folded > expression. Also as analyzed in comment, I think this change won't result in substantial > code gen difference. > I also need to adjust get_computation_aff for test case gcc.dg/tree-ssa/reassoc-19.c. > Well, I think the changed behavior is correct, but for case the original pointer candidate > is chosen, it should be unnecessary to compute in uutype. Also this adjustment only > generates (unsigned)(pointer + offset) which is generated by tree-affine.c. > Bootstrap and test on x86_64 and AArch64. Is it OK? Hmm. What is the desired goal? To have all elts added have comb->type as type? Then the type passed to add_elt_to_tree is redundant with comb->type. It looks like it is always passed comb->type now. ISTR from past work in this area that it was important for pointer combinations to allow both pointer and sizetype elts at least. Your change is incomplete I think, for the scale == -1 and POINTER_TYPE_P case elt is sizetype now, not of pointer type. As said above, we are trying to maintain both pointer and sizetype elts with like: if (scale == 1) { if (!expr) { if (POINTER_TYPE_P (TREE_TYPE (elt))) return elt; else return fold_convert (type1, elt); } where your earilier fold to type would result in not all cases handled the same (depending whether scale was -1 for example). Thus - shouldn't we simply drop the type argument (or rather the comb one? that wide_int_ext_for_comb looks weird given we get a widest_int as input and all the other wide_int_ext_for_comb calls around). And unconditionally convert to type, simplifying the rest of the code? Richard. > 2017-03-27 Bin Cheng > > PR tree-optimization/80153 > * tree-affine.c (add_elt_to_tree): Convert to type as required > by function's parameter. > * tree-ssa-loop-ivopts.c (alloc_iv): Pass in consistent types. > (get_computation_aff): Use utype directly for original candidate. > > gcc/testsuite/ChangeLog > 2017-03-27 Bin Cheng > > PR tree-optimization/80153 > * gcc.c-torture/execute/pr80153.c: New.