From: Richard Sandiford <richard.sandiford@linaro.org>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: gcc@gcc.gnu.org
Subject: Re: RFC: Representing vector lane load/store operations
Date: Wed, 23 Mar 2011 14:41:00 -0000 [thread overview]
Message-ID: <g439mdx5l1.fsf@linaro.org> (raw)
In-Reply-To: <AANLkTin0KvXc+98x1Oa1u9qfFM=VBGxq=jGo_cCXFEqZ@mail.gmail.com> (Richard Guenther's message of "Wed, 23 Mar 2011 15:28:17 +0100")
Richard Guenther <richard.guenther@gmail.com> writes:
> On Wed, Mar 23, 2011 at 3:13 PM, Richard Sandiford
> <richard.sandiford@linaro.org> wrote:
>> Richard Guenther <richard.guenther@gmail.com> writes:
>>>>> For your case in question the vectorizer would create local vars with
>>>>> that mode, knowing it is supported, so I don't see big problems for
>>>>> that particular case.
>>>>
>>>> The problem is that I'd like to use this for intrinsics as well as for
>>>> automatic vectorisation. E.g. I'd like:
>>>>
>>>> typedef struct int8x16x4_t
>>>> {
>>>> int8x16_t val[4];
>>>> } int8x16x4_t;
>>>>
>>>> to have non-BLKmode as well. arm_neon.h uses this type of structure
>>>> to represent compounds vectors. But once the type is defined (with Neon
>>>> support enabled), there's nothing to stop someone using the type
>>>> (not the intrinsics) in a function that has Neon disabled. We mustn't
>>>> use the special mode in such cases, because there aren't enough GPRs to
>>>> store it. It should be treated as BLKmode instead. Which I suppose
>>>> is the same situation as...
>>>
>>> I'd use non-BLKmode for the above unconditionally.
>>
>> But without Neon, there aren't enough registers to store the structure.
>> Any use of the Neon mode would just lead to a reload failure. Even if
>> we think it's not sensible to use the type without Neon, we need a better
>> diagnostic than that.
>>
>> So I think this mode has to be conditional in exactly the way that
>> vector modes are, or be subject to the same diagnostics that you
>> were suggesting for 128-bit types.
>>
>> I was actually thinking along the lines of having a target hook such as:
>>
>> array_mode_supported_p (tree elemtype, unsigned HOST_WIDE_INT size)
>>
>> which would return true if ELEMTYPE[SIZE] should use non-BLKmode where
>> possible. When it returns true, we'd pass 0 rather than 1 to this
>> mode_for_size_tree call (from the ARRAY_TYPE case in layout_type):
>>
>> /* One-element arrays get the component type's mode. */
>> if (simple_cst_equal (TYPE_SIZE (type),
>> TYPE_SIZE (TREE_TYPE (type))))
>> SET_TYPE_MODE (type, TYPE_MODE (TREE_TYPE (type)));
>> else
>> SET_TYPE_MODE (type, mode_for_size_tree (TYPE_SIZE (type),
>> MODE_INT, 1));
>>
>> This would have the "advantage" (as I see it) of working with the
>> generic vector extensions too. E.g. if a user defines their own
>> 3-element-array-of-vector type, they would benefit from the same
>> handling as the Neon-specific intrinsics and the vectoriser-generated
>> arrays.
>
> So the 3-element-array-of-vector type has the vector mode of a single
> element?
No, it has a wider, non-vector mode. At the moment, ARM uses integer
modes for this, and after trying a few variations, I think that's
actually the best compromise. So the uint8x16x4_t ought to have a
64-byte integer type(!), which ARM defines as XImode:
INT_MODE (XI, 64);
> I also don't see how a user could want to have a non-BLK mode on such
> array types (consider them being part of a struct - how would that
> affect argument passing and other ABI details?).
The point is that we shouldn't use the mode for the ABI anyway. Even the
intrinsic-defined types (like uint8x16x4_t above) should be passed in
the same way as BLKmode structures would.
>>> I'd say if somebody writes
>>>
>>> v4sf float_vec;
>>>
>>> void __attribute__((target("no-sse")))
>>> foo (void)
>>> {
>>> float_vec += float_vec;
>>> }
>>>
>>> he deserves to get a diagnostic. Thus, even for global decls I think we
>>> can reject such uses. Complication arises whenever we do not see
>>> a decl, like for
>>>
>>> void foo(v4sf *x)
>>> {
>>> }
>>>
>>> which we could of course reject (at function definition time) if an
>>> unsupported type is used in this way. But the function might
>>> not even dereference that pointer ...
>>
>> it sounds like you think there's no point supporting generic vectors
>> when no underlying hardware support is available.
>
> Well, I meant if the user compiles with -msse, declares such a
> global var (which means it gets V4SFmode and not BLKmode)
> and then uses it in a function where he explicitly disables SSE
> then something is wrong. If he declares a BLKmode global
> then generic vector support will happily trigger and make it work.
Ah, OK. I'm just not sure whether, to take a MIPS example,
MIPS16 functions in a "-mno-mips16" compile should behave
differently from unannotated functions in a "-mips16" compile.
> If it's just three element array-of-vector types you need why not expose
> it via attribute((mode(xyz))) only? You could alias that mode to BLKmode
> if neon is not enabled ...
I don't think that really changes anything. Getting the non-BLK mode
on the array type seems like the easy part. The difficult part is
dealing with the fallout when the array is defined in a Neon context
and used in a non-Neon context.
Richard
next prev parent reply other threads:[~2011-03-23 14:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-22 16:52 Richard Sandiford
2011-03-22 17:10 ` Richard Guenther
2011-03-22 19:43 ` Richard Sandiford
2011-03-23 9:23 ` Richard Guenther
2011-03-23 10:38 ` Richard Sandiford
2011-03-23 11:52 ` Richard Guenther
2011-03-23 12:18 ` Richard Sandiford
2011-03-23 12:37 ` Richard Guenther
2011-03-23 13:01 ` Richard Sandiford
2011-03-23 13:14 ` Richard Guenther
2011-03-23 14:14 ` Richard Sandiford
2011-03-23 14:28 ` Richard Guenther
2011-03-23 14:41 ` Richard Sandiford [this message]
2011-03-29 12:50 ` Richard Sandiford
2011-03-29 14:05 ` Richard Guenther
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=g439mdx5l1.fsf@linaro.org \
--to=richard.sandiford@linaro.org \
--cc=gcc@gcc.gnu.org \
--cc=richard.guenther@gmail.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).