This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: "generic" vectorization?


On Jan 6, 2004, at 2:44 PM, Falk Hueffner wrote:
Dale Johannesen <dalej@apple.com> writes:
On Jan 2, 2004, at 2:19 PM, Falk Hueffner wrote:
I was just wondering about vectorization for platforms without proper
vector instructions like Alpha. Sometimes, vectorization could still
be a noticeable win, for example transforming

...
Does this seem like a good idea? Are there other targets which would
profit from it?

Yes, most RISCs, but you have to watch out for alignment.

Isn't that the same for architectures with special vector instructions? I was under the impression that most require strict alignment, so I was assuming the infrastructure would already ensure this...

Your example transformation


char *s1, *s2, *d;
for (i = 0; i < 8; i++)
  d[i] = s1[i] + s2[i]

to

uint64_t x = load(s1), y = load(s2);
uint64_t signmask = 0x8080808080808080;
uint64_t signs = (x ^ y) & signmask;
x &= ~signmask;
y &= ~signmask;
x += y;
x ^= signs;
store(d,  x);

only works on ppc if s1, s2, d are 4-byte aligned. And that's using 64-bit ints;
for vectors the requirement is 16-byte alignment. Of course you can insert
code to check at runtime, but that's painful and eats up a lot of the benefit.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]