From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29637 invoked by alias); 28 Aug 2014 06:44:35 -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 29624 invoked by uid 89); 28 Aug 2014 06:44:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail2-relais-roc.national.inria.fr Received: from mail2-relais-roc.national.inria.fr (HELO mail2-relais-roc.national.inria.fr) (192.134.164.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 28 Aug 2014 06:44:32 +0000 Received: from ip-51.net-81-220-141.rev.numericable.fr (HELO laptop-mg.local) ([81.220.141.51]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 28 Aug 2014 08:44:29 +0200 Date: Thu, 28 Aug 2014 06:44:00 -0000 From: Marc Glisse Reply-To: gcc-patches@gcc.gnu.org To: Kugan cc: Uros Bizjak , "gcc-patches@gcc.gnu.org" , Richard Biener , Jakub Jelinek Subject: Re: [PATCH 2/2] Enable elimination of zext/sext In-Reply-To: <53FEA5F0.9070906@linaro.org> Message-ID: References: <53FDD6CA.7000400@linaro.org> <53FEA5F0.9070906@linaro.org> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-SW-Source: 2014-08/txt/msg02540.txt.bz2 On Thu, 28 Aug 2014, Kugan wrote: > 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] Why do you believe that is wrong? Assuming _344 has a 32 bit type with wrapping overflow, this is just doing the wrapping modulo 2^32. -- Marc Glisse