From: Kenneth Zadeck <zadeck@naturalbridge.com>
To: gcc-patches@gcc.gnu.org, mikestump@comcast.net,
rdsandiford@googlemail.com
Subject: Re: [wide-int] Make shifted_mask more forgiving
Date: Sat, 02 Nov 2013 14:02:00 -0000 [thread overview]
Message-ID: <527505E9.3020504@naturalbridge.com> (raw)
In-Reply-To: <87d2mjja1q.fsf@talisman.default>
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;
prev parent reply other threads:[~2013-11-02 14:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-02 11:52 Richard Sandiford
2013-11-02 14:02 ` Kenneth Zadeck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=527505E9.3020504@naturalbridge.com \
--to=zadeck@naturalbridge.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=mikestump@comcast.net \
--cc=rdsandiford@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).