public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <richard.guenther@gmail.com>
To: Richard Guenther <richard.guenther@gmail.com>,
	Chung-Lin Tang <cltang@codesourcery.com>,
		gcc-patches <gcc-patches@gcc.gnu.org>,
	richard.sandiford@linaro.org
Subject: Re: [patch] Fix PR48183, NEON ICE in emit-rtl.c:immed_double_const() under -g
Date: Tue, 29 Mar 2011 13:18:00 -0000	[thread overview]
Message-ID: <AANLkTikwD_FO+kRJB67JnsCz6aj7ZStQRFrxf7BRHrpx@mail.gmail.com> (raw)
In-Reply-To: <g4bp0uqh3m.fsf@linaro.org>

On Tue, Mar 29, 2011 at 1:52 PM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> Richard Guenther <richard.guenther@gmail.com> writes:
>> On Thu, Mar 24, 2011 at 11:57 AM, Richard Sandiford
>> <richard.sandiford@linaro.org> wrote:
>>> Chung-Lin Tang <cltang@codesourcery.com> writes:
>>>> PR48183 is a case where ARM NEON instrinsics, under -O -g, produce debug
>>>> insns that tries to expand OImode (32-byte integer) zero constants, much
>>>> too large to represent as two HOST_WIDE_INTs; as the internals manual
>>>> indicates, such large constants are not supported in general, and ICEs
>>>> on the GET_MODE_BITSIZE(mode) == 2*HOST_BITS_PER_WIDE_INT assertion.
>>>>
>>>> This patch allows the cases where the large integer constant is still
>>>> representable using a single CONST_INT, such as zero(0). Bootstrapped
>>>> and tested on i686 and x86_64, cross-tested on ARM, all without
>>>> regressions. Okay for trunk?
>>>>
>>>> Thanks,
>>>> Chung-Lin
>>>>
>>>> 2011-03-20  Chung-Lin Tang  <cltang@codesourcery.com>
>>>>
>>>>       * emit-rtl.c (immed_double_const): Allow wider than
>>>>       2*HOST_BITS_PER_WIDE_INT mode constants when they are
>>>>       representable as a single const_int RTX.
>>>
>>> I realise this might be seen as a good expedient fix, but it makes
>>> me a bit uneasy.  Not a very constructive rationale, sorry.
>>>
>>> For this particular case, the problem is that vst2q_s32 and the
>>> like initialise a union directly:
>>>
>>>  union { int32x4x2_t __i; __builtin_neon_oi __o; } __bu = { __b; };
>>>
>>> and this gets translated into a zeroing of the whole union followed
>>> by an assignment to __i:
>>>
>>>  __bu = {};
>>>  __bu.__i = __b;
>>
>> Btw, this looks like a missed optimization in gimplification.  Worth
>> a bugreport (or even a fix).  Might be a target but as well, dependent
>> on how __builtin_neon_oi looks like.  Do you have a complete testcase
>> that reproduces the above with a cross?
>
> Yeah, build cc1 for arm-linux-gnueabi and compile the attached
> testcase (from Chung-Lin) using:
>
>  -O2 -g -mfpu=neon -mfloat-abi=softfp

It seems that count_type_elements is confused by unions and thus clearing
is always performed.  I fail to see why count_type_elements could not
simply return 1 for all unions (non-initialized parts have undefined rather
than zero content).

categorize_ctor_elements also counts 8 elements for some reason.

The following fixes it for me:

Index: gcc/expr.c
===================================================================
--- gcc/expr.c  (revision 171606)
+++ gcc/expr.c  (working copy)
@@ -5059,7 +5059,7 @@ count_type_elements (const_tree type, bo

     case UNION_TYPE:
     case QUAL_UNION_TYPE:
-      return -1;
+      return 1;

     case COMPLEX_TYPE:
       return 2;

disclaimer: completely untested, might confuse the hell out of
output_init_constructor and friends.

Richard.

> Rchard
>
>

      reply	other threads:[~2011-03-29 12:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-20 11:02 Chung-Lin Tang
2011-03-20 11:11 ` Richard Guenther
2011-03-21 12:47   ` Chung-Lin Tang
2011-03-24 10:57 ` Richard Sandiford
2011-03-24 13:49   ` Julian Brown
2011-03-29 10:56     ` Richard Sandiford
2011-03-30 11:57       ` Julian Brown
2011-03-29 11:12   ` Richard Guenther
2011-03-29 12:15     ` Richard Sandiford
2011-03-29 13:18       ` Richard Guenther [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=AANLkTikwD_FO+kRJB67JnsCz6aj7ZStQRFrxf7BRHrpx@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=cltang@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.sandiford@linaro.org \
    /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).