From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24876 invoked by alias); 20 Nov 2018 10:49:06 -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 24556 invoked by uid 89); 20 Nov 2018 10:48:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,RCVD_IN_DNSWL_NONE,SEM_URI,SEM_URIRED,SPF_PASS autolearn=ham version=3.3.2 spammy=Very, Updated, H*r:ip*209.85.166.194, H*RU:209.85.166.194 X-HELO: mail-it1-f194.google.com Received: from mail-it1-f194.google.com (HELO mail-it1-f194.google.com) (209.85.166.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Nov 2018 10:48:44 +0000 Received: by mail-it1-f194.google.com with SMTP id x19so2662738itl.1 for ; Tue, 20 Nov 2018 02:48:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dwCS2vQu7tvILPXbt678EFQSQ0AiVOgLOBzIx+QDTOQ=; b=adzYcU5X9Ls5r9+fDeHBbymLbZBzKTBGhkuowN96fP+5Q0PPEZbmHO2OnRJYH1bszI KrMXYYFqCPXKH446LKINLcqxs0dMr3fxGyK/Ypmc6jUovtr5MvawsqcukIiJQJkmz3qp gZc99Sxxp+BwG5SMuLWDxsfc+NhOQQJRBlLX2XY+awnRIGI6rGOjB4S6+5jEDTJcVE+B 7f05HgQNEVmFSKnYS263JHA6/6V7EQWyHeUtKFdwvHVzUgz2nPP1TtrFOLtgkU6XE45D l/ofD/te0LSmgUJAWoXvuO84u1ZJJw1ndRM5B2GDJ0JxKzerHo2ySojcf45ngFKuZ3hN CK+Q== MIME-Version: 1.0 References: <41044492-d88d-4b02-804e-bbc76465457d.bin.cheng@linux.alibaba.com> <9c7fffcd-0bbe-4109-ad3f-7e2617abae49.bin.cheng@linux.alibaba.com> In-Reply-To: From: "Bin.Cheng" Date: Tue, 20 Nov 2018 10:49:00 -0000 Message-ID: Subject: Re: [PATCH PR84648]Adjust loop exit conditions for loop-until-wrap cases. To: Christophe Lyon Cc: bin.cheng@linux.alibaba.com, gcc-patches List , Richard Guenther Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-11/txt/msg01703.txt.bz2 On Mon, Nov 19, 2018 at 9:17 PM Christophe Lyon wrote: > > On Wed, 14 Nov 2018 at 11:10, bin.cheng wrote: > > > > ------------------------------------------------------------------ > > Sender:Richard Biener > > Sent at:2018 Nov 13 (Tue) 23:03 > > To:bin.cheng > > Cc:GCC Patches > > Subject:Re: [PATCH PR84648]Adjust loop exit conditions for loop-until-wrap cases. > > > > > > > > On Sun, Nov 11, 2018 at 9:02 AM bin.cheng wrote: > > >> > > >> Hi, > > >> This patch fixes PR84648 by adjusting exit conditions for loop-until-wrap cases. > > >> It only handles simple cases in which IV.base are constants because we rely on > > >> current niter analyzer which doesn't handle parameterized bound in wrapped > > >> case. It could be relaxed in the future. > > >> > > >> Bootstrap and test on x86_64 in progress. > > > > > > Please use TYPE_MIN/MAX_VALUE or wi::min/max_value consistently. > > > Either tree_int_cst_equal (iv0->base, TYPE_MIN_VALUE (type)) or > > > wide_int_to_tree (niter_type, wi::max_value (TYPE_PRECISION (type), > > > TYPE_SIGN (type))). > > > > > > Also > > > > > > + iv0->base = low; > > > + iv0->step = fold_convert (niter_type, integer_one_node); > > > > > > build_int_cst (niter_type, 1); > > > > > > + iv1->base = high; > > > + iv1->step = integer_zero_node; > > > > > > build_int_cst (niter_type, 0); > > Fixed, thanks for reviewing. > > > > > > > > With the code, what happens to signed IVs? I suppose we figure out things > > > earlier by means of undefined overflow? > > The code takes advantage of signed undefined overflow and handle it as wrap. > > In the reported test case, we have following IL: > > : > > goto ; [INV] > > > > : > > i_4 = i_2 + 1; > > > > : > > # i_2 = PHI <0(2), i_4(3)> > > i.0_1 = (signed int) i_2; > > if (i.0_1 >= 0) > > goto ; [INV] > > else > > goto ; [INV] > > > > So the IV is actually transformed into signed int, we rely on scev to understand > > type conversion correctly and generate (int){0, 1} for i.0_1. Is this reasonable? > > > > Updated patch attached, bootstrap and test on x86_64. > > > > Thanks, > > bin > > > > 2018-11-11 Bin Cheng > > > > PR tree-optimization/84648 > > * tree-ssa-loop-niter.c (adjust_cond_for_loop_until_wrap): New. > > (number_of_iterations_cond): Adjust exit cond for loop-until-wrap case > > by calling adjust_cond_for_loop_until_wrap. > > > > 2018-11-11 Bin Cheng > > > > PR tree-optimization/84648 > > * gcc.dg/tree-ssa/pr84648.c: New test. > > * gcc.dg/pr68317.c: Add warning check on overflow. > > > Hi Bin, > > Since you committed this patch (r266171), I've noticed a regression > in fortran: Very sorry for the breakage. It's reported as pr88044, I will investigate it. Thanks, bin > FAIL: gfortran.dg/transfer_intrinsic_3.f90 -O3 -fomit-frame-pointer > -funroll-loops -fpeel-loops -ftracer -finline-functions execution > test > FAIL: gfortran.dg/transfer_intrinsic_3.f90 -O3 -g execution test > on arm-none-linux-gnueabihf > --with-cpu cortex-a5 > --with-fpu vfpv3-d16-fp16 > > cortex-a9+neon-fp16, cortex-a15+neon-vfpv4 and > cortex-a57+crypto-neon-fp-armv8 are still OK. > > Christophe