From patchwork Thu Aug 28 03:45:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 36142 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 443A32054F for ; Thu, 28 Aug 2014 03:46:20 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id eu11sf11800603pac.11 for ; Wed, 27 Aug 2014 20:46:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:x-original-sender :x-original-authentication-results:content-type :content-transfer-encoding; bh=DMA0QzI2eJ+kgYdL2fGpCWPeT83W78pj6h/rWNmoc3k=; b=datWTN1zJHYn5gH+NaYJ0cQ4HZDtiSy3Yw8SanORCQ5x53stKHpdDCJgttOxu+xhmk H0eTXuqdl5/Ne52zmAaZUkyB5Tq0VQFgmPkDuZoAergdP4ogt1VqM4g983FzAObzslqF TBYEkVfevQAmX8UcZxJq+vwuL5CH3EwOBHJL6jSKaIbHlxwXLeploZNTAYgUGdhpHV6e PLZqY4EZ3S4Sxv5SG/EHX8t34e6rxdagewoNJadrkcM6qo4Xvo2ix+GVjWVI58O6dFn/ IajemGkBovx2AhW//x8wp5GF3cWndQebSUzagokUmaoPWsMjSnMHmoXd45ZzTCJ+Jk1Q erpQ== X-Gm-Message-State: ALoCoQkY33oivznkPOmfscDzh/sqo+IuaiqsYfbgCZ2ZxuMyUUB5Xne5OsvmUAgpaxsOPaRbWqeM X-Received: by 10.70.130.135 with SMTP id oe7mr858998pdb.9.1409197579464; Wed, 27 Aug 2014 20:46:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.48.35 with SMTP id n32ls86414qga.25.gmail; Wed, 27 Aug 2014 20:46:19 -0700 (PDT) X-Received: by 10.52.249.66 with SMTP id ys2mr785696vdc.41.1409197579296; Wed, 27 Aug 2014 20:46:19 -0700 (PDT) Received: from mail-vc0-x235.google.com (mail-vc0-x235.google.com [2607:f8b0:400c:c03::235]) by mx.google.com with ESMTPS id ci16si2706556vdb.93.2014.08.27.20.46.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 27 Aug 2014 20:46:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::235 as permitted sender) client-ip=2607:f8b0:400c:c03::235; Received: by mail-vc0-f181.google.com with SMTP id ij19so205154vcb.40 for ; Wed, 27 Aug 2014 20:46:19 -0700 (PDT) X-Received: by 10.52.253.39 with SMTP id zx7mr922936vdc.2.1409197579090; Wed, 27 Aug 2014 20:46:19 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp173880vcb; Wed, 27 Aug 2014 20:46:18 -0700 (PDT) X-Received: by 10.70.102.200 with SMTP id fq8mr1740542pdb.152.1409197577644; Wed, 27 Aug 2014 20:46:17 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id sm7si4101017pab.81.2014.08.27.20.46.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Aug 2014 20:46:17 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-376325-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 6816 invoked by alias); 28 Aug 2014 03:46:02 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 6796 invoked by uid 89); 28 Aug 2014 03:46:00 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f52.google.com Received: from mail-pa0-f52.google.com (HELO mail-pa0-f52.google.com) (209.85.220.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 28 Aug 2014 03:45:59 +0000 Received: by mail-pa0-f52.google.com with SMTP id eu11so743446pac.39 for ; Wed, 27 Aug 2014 20:45:57 -0700 (PDT) X-Received: by 10.68.98.194 with SMTP id ek2mr40441pbb.103.1409197556994; Wed, 27 Aug 2014 20:45:56 -0700 (PDT) Received: from [10.1.1.2] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by mx.google.com with ESMTPSA id qz2sm7909600pab.27.2014.08.27.20.45.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Aug 2014 20:45:56 -0700 (PDT) Message-ID: <53FEA5F0.9070906@linaro.org> Date: Thu, 28 Aug 2014 13:45:52 +1000 From: Kugan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Uros Bizjak , "gcc-patches@gcc.gnu.org" , Richard Biener CC: Jakub Jelinek Subject: Re: [PATCH 2/2] Enable elimination of zext/sext References: <53FDD6CA.7000400@linaro.org> In-Reply-To: <53FDD6CA.7000400@linaro.org> X-IsSubscribed: yes X-Original-Sender: kugan.vivekanandarajah@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::235 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 On 27/08/14 23:02, Kugan wrote: > On 27/08/14 20:01, Uros Bizjak wrote: >> Hello! >> >>> 2014-08-07 Kugan Vivekanandarajah >>> >>> * calls.c (precompute_arguments): Check >>> promoted_for_signed_and_unsigned_p and set the promoted mode. >>> (promoted_for_signed_and_unsigned_p): New function. >>> (expand_expr_real_1): Check promoted_for_signed_and_unsigned_p >>> and set the promoted mode. >>> * expr.h (promoted_for_signed_and_unsigned_p): New function definition. >>> * cfgexpand.c (expand_gimple_stmt_1): Call emit_move_insn if >>> SUBREG is promoted with SRP_SIGNED_AND_UNSIGNED. >> >> This patch regresses: >> >> Running target unix >> FAIL: libgomp.fortran/simd7.f90 -O2 execution test >> FAIL: libgomp.fortran/simd7.f90 -Os execution test >> > > [snip] > >> When compiling this code, we have: >> >> lhs = _63 >> target = (subreg/s/v/u:SI (reg:DI 145 [ D.1694 ]) 0) >> temp = (subreg:SI (reg:DI 540) 0) >> >> So, the code assumes that it is possible to copy (reg:DI 540) directly >> to (reg:DI 154). However, this is not the case, since we still have >> garbage in the top 32bits. >> >> Reverting the part above fixes the runtime failure, since (insn 599) is now: >> >> (insn 599 598 0 (set (reg:DI 145 [ D.1694 ]) >> (zero_extend:DI (subreg:SI (reg:DI 540) 0))) -1 >> (nil)) >> >> It looks to me that we have also to check the temp with SUBREG_PROMOTED_*. > > Sorry for the breakage. I am looking into this now and I can reproduce > it on qemu-alpha. > > I have noticed the following VRP data which is used in deciding this > erroneous removal. It seems suspicious to me. > > _343: [2147483652, 2147483715] > _344: [8, 134] > _345: [8, 134] > > _343 = ivtmp.179_52 + 2147483645; > _344 = _343 * 2; > _345 = (integer(kind=4)) _344; > > Error comes from the third statement. In tree-vrp.c, in extract_range_from_binary_expr_1, there is a loss of precision and the value_range is truncated. For the test-case provided by Uros, it is _344 = _343 * 2; [...,0x100000008], precision = 384 [...,0x100000086], precision = 384 and it is converted to following when it goes from wide_int to tree. [8, 134] How about doing something like this to fix it. If this looks reasonable I will do proper testing and post the results with the Changelog. Thanks, Kugan diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index d16fd8a..c0fb902 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -2625,6 +2625,8 @@ extract_range_from_binary_expr_1 (value_range_t *vr, > vrp_int_cst; vrp_int sizem1 = wi::mask (prec, false); vrp_int size = sizem1 + 1; + vrp_int type_min = vrp_int_cst (TYPE_MIN_VALUE (expr_type)); + vrp_int type_max = vrp_int_cst (TYPE_MAX_VALUE (expr_type)); /* Extend the values using the sign of the result to PREC2. From here on out, everthing is just signed math no matter @@ -2688,7 +2690,9 @@ extract_range_from_binary_expr_1 (value_range_t *vr, /* diff = max - min. */ prod2 = prod3 - prod0; - if (wi::geu_p (prod2, sizem1)) + if (wi::geu_p (prod2, sizem1) + || wi::lts_p (prod0, type_min) + || wi::gts_p (prod3, type_max)) { /* the range covers all values. */ set_value_range_to_varying (vr);