Bug 53024 - Support vector_size that is not a power of 2
Summary: Support vector_size that is not a power of 2
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.8.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: documentation
Depends on:
Blocks:
 
Reported: 2012-04-17 20:39 UTC by Marc Glisse
Modified: 2012-11-16 20:03 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-04-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Glisse 2012-04-17 20:39:50 UTC
Hello,

typedef float VEC __attribute__ ((__vector_size__ (12)));

fails to compile with the message:
error: number of components of the vector not a power of two

This is quite clear, and I guess it makes sense. However, http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html says:

"Specifying a combination that is not valid for the current architecture will cause GCC to synthesize the instructions using a narrower mode."

so I was expecting gcc to handle it somehow. Could we add a sentence, anywhere in that page, that makes the requirement that the size is a power of 2 explicit? Or if the requirement can be lifted... (I don't care so much about 3 float, I can just store 4 and ignore the last, but I do care about 12 double and don't want to store 16 until we get 512bit vectors)
Comment 1 Richard Biener 2012-04-18 10:15:29 UTC
Confirmed as documentation issue.  We can't easily lift this restriction
because we have

/* For a VECTOR_TYPE, this is the number of sub-parts of the vector.  */
#define TYPE_VECTOR_SUBPARTS(VECTOR_TYPE) \
  (((unsigned HOST_WIDE_INT) 1) \
   << VECTOR_TYPE_CHECK (VECTOR_TYPE)->type_common.precision)

and

struct GTY(()) tree_type_common {
...
  unsigned int precision : 10;

10 bits of precision would limit us to vectors with 1024 elements if we'd
not have the power-of-two restriction.  (not sure what a sane limit would be,
but 1024 byte vectors do not look too far off).
Comment 2 Marc Glisse 2012-09-27 10:06:29 UTC
Author: glisse
Date: Thu Sep 27 10:06:23 2012
New Revision: 191800

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191800
Log:
2012-09-27  Marc Glisse  <marc.glisse@inria.fr>

	PR c/53024
	PR c++/54427
	* gcc/doc/extend.texi (Vector Extensions): C++ improvements.
	Power of 2 size requirement.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/doc/extend.texi
Comment 3 Marc Glisse 2012-09-27 10:14:38 UTC
Documentation fixed.

It might make sense to keep it open as a RFE to support non-powers of 2 some time in the distant future. I'll retitle the bug in a few days if there are no comments.
Comment 4 Marc Glisse 2012-11-16 16:06:28 UTC
Not a priority.
Comment 5 Andrew Pinski 2012-11-16 18:18:16 UTC
I don't think we can ever support vector size of non power 2 size.
Comment 6 Marc Glisse 2012-11-16 20:03:05 UTC
(In reply to comment #5)
> I don't think we can ever support vector size of non power 2 size.

I don't think we *will* ever support them (too much work, too little benefit), but I am not sure why we couldn't in principle.