From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28365 invoked by alias); 2 Nov 2013 14:02:21 -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 28352 invoked by uid 89); 2 Nov 2013 14:02:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-qc0-f177.google.com Received: from mail-qc0-f177.google.com (HELO mail-qc0-f177.google.com) (209.85.216.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 02 Nov 2013 14:02:20 +0000 Received: by mail-qc0-f177.google.com with SMTP id u18so3006714qcx.8 for ; Sat, 02 Nov 2013 07:02:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=6T2Tlk3OagRxc+kSSlUJc+tJNynX4fvt03hzafu793M=; b=PLeJUo+yfJ3giacQVcw4pwXgfG5s7rtkV53I3VzUkhgTwe0r6ZTYwuxjXr0BqweHq9 rIXVFkgNW8hm5HHGhtZXM0RS9CBBGI2SBGhQrbvMN1N6Gu2muLdPPEMvuY9pYYv8NtZa FKAE5e1woKMrqwRVHOhSphCE/uoFXuoW0dnUX1uyafEp4JQ7ccthyF2Eu8Kc4N9YGnr9 psfIGX2ytEmpHnUd2KK8ItDy6e8ioZHqn+Ljs2RjgaIXkPRrkEYOey7622JWexz2RULd r+3LBBEWaXgZPWR5sy2ho76lowyTblps4WOimGKXwE9F5Wx+hFU2Cbfm2l0/d/pXTwb1 AJAg== X-Gm-Message-State: ALoCoQmr4bLoyLDSI1xUOQf8njp1gKtVeC+q4W5xXaRNqux4V37efblonnQpRIypfzUw/bdNFT24 X-Received: by 10.224.163.132 with SMTP id a4mr6584157qay.54.1383400938813; Sat, 02 Nov 2013 07:02:18 -0700 (PDT) Received: from moria.site (pool-98-113-157-168.nycmny.fios.verizon.net. [98.113.157.168]) by mx.google.com with ESMTPSA id n7sm32758408qai.1.2013.11.02.07.02.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 02 Nov 2013 07:02:18 -0700 (PDT) Message-ID: <527505E9.3020504@naturalbridge.com> Date: Sat, 02 Nov 2013 14:02:00 -0000 From: Kenneth Zadeck User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org, mikestump@comcast.net, rdsandiford@googlemail.com Subject: Re: [wide-int] Make shifted_mask more forgiving References: <87d2mjja1q.fsf@talisman.default> In-Reply-To: <87d2mjja1q.fsf@talisman.default> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2013-11/txt/msg00106.txt.bz2 this is fine with me. kenny On 11/02/2013 07:52 AM, Richard Sandiford wrote: > r201806 added some extra checks to the handling of CONCAT when expanding > assignments. This was to fix an ICE on gcc.dg/pr48335-2.c for ppc. > > I tripped over this because it also causes the assembly output for > the test to change. I tried backing out the patch and the ICE was > from the assert in wide-int.cc:shifted_mask: > > gcc_assert (start < 4 * MAX_BITSIZE_MODE_ANY_INT); > > However, in this case, the mask was being generated by mask_rtx, > which specifically allows inputs that are out of range of the mode: > > /* Return a constant integer mask value of mode MODE with BITSIZE ones > followed by BITPOS zeros, or the complement of that if COMPLEMENT. > The mask is truncated if necessary to the width of mode MODE. The > mask is zero-extended if BITSIZE+BITPOS is too small for MODE. */ > > So I don't think these inputs should trigger an ICE, even if in this > particularly case they're conceptually wrong for some reason. > > Since wide-int.cc:shifted_mask already handles zero-width masks > and cases where the end bit is out of range, I think we should > handle the start being out of range too. > > It might be that 201806 is a good thing anyway (no idea either way), > but I think it should go directly on mainline first if so. > > Tested on powerpc64-linux-gnu and x86_64-linux-gnu. It fixes the > pr48335-2.c assembly differences. OK to install? > > Thanks, > Richard > > > Index: gcc/expr.c > =================================================================== > --- gcc/expr.c 2013-11-02 11:15:32.739837369 +0000 > +++ gcc/expr.c 2013-11-02 11:15:42.562911693 +0000 > @@ -4765,14 +4765,12 @@ expand_assignment (tree to, tree from, b > && (bitpos == 0 || bitpos == mode_bitsize / 2)) > result = store_expr (from, XEXP (to_rtx, bitpos != 0), false, > nontemporal); > - else if (bitpos + bitsize <= mode_bitsize / 2 > - && bitpos+bitsize <= mode_bitsize) > + else if (bitpos + bitsize <= mode_bitsize / 2) > result = store_field (XEXP (to_rtx, 0), bitsize, bitpos, > bitregion_start, bitregion_end, > mode1, from, > get_alias_set (to), nontemporal); > - else if (bitpos >= mode_bitsize / 2 > - && bitpos+bitsize <= mode_bitsize) > + else if (bitpos >= mode_bitsize / 2) > result = store_field (XEXP (to_rtx, 1), bitsize, > bitpos - mode_bitsize / 2, > bitregion_start, bitregion_end, > @@ -4791,12 +4789,8 @@ expand_assignment (tree to, tree from, b > } > else > { > - HOST_WIDE_INT extra = 0; > - if (bitpos+bitsize > mode_bitsize) > - extra = bitpos+bitsize - mode_bitsize; > rtx temp = assign_stack_temp (GET_MODE (to_rtx), > - GET_MODE_SIZE (GET_MODE (to_rtx)) > - + extra); > + GET_MODE_SIZE (GET_MODE (to_rtx))); > write_complex_part (temp, XEXP (to_rtx, 0), false); > write_complex_part (temp, XEXP (to_rtx, 1), true); > result = store_field (temp, bitsize, bitpos, > Index: gcc/wide-int.cc > =================================================================== > --- gcc/wide-int.cc 2013-11-02 11:15:32.740837376 +0000 > +++ gcc/wide-int.cc 2013-11-02 11:15:42.562911693 +0000 > @@ -748,18 +748,16 @@ unsigned int > wi::shifted_mask (HOST_WIDE_INT *val, unsigned int start, unsigned int width, > bool negate, unsigned int prec) > { > - gcc_assert (start < 4 * MAX_BITSIZE_MODE_ANY_INT); > - > - if (start + width > prec) > - width = prec - start; > - unsigned int end = start + width; > - > - if (width == 0) > + if (start >= prec || width == 0) > { > val[0] = negate ? -1 : 0; > return 1; > } > > + if (width > prec - start) > + width = prec - start; > + unsigned int end = start + width; > + > unsigned int i = 0; > while (i < start / HOST_BITS_PER_WIDE_INT) > val[i++] = negate ? -1 : 0;