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] | |
Hi
I hope someone can help me. I've been trying to write some tight integer loops
in way that could be auto-vectorized, saving me to write assembler or using
specific vectorization extensions. Unfortunately I've not yet managed to make
gcc vectorize any of them.
I've simplified the case to just perform the very first operation in the loop;
converting from two's complement to sign-and-magnitude.
I've then used -ftree-vectorizer-verbose to examine if and if not, why not the
loops were not vectorized, but I am afraid I don't understand the output.
The simplest version of the loop is here (it appears the branch is not a
problem, but I have another version without).
inline uint16_t transsign(int16_t v) {
if (v<0) {
return 0x8000U | (1-v);
} else {
return v;
}
}
It very simply converts in a fashion that maintains the full effective bit-
width.
The error from the vectorizer is:
vectorizesign.cpp:42: note: not vectorized: relevant stmt not supported:
v.1_16 = (uint16_t) D.2157_11;
It appears the unsupported operation in vectorization is the typecast from
int16_t to uint16_t, can this really be the case, or is the output misleading?
If it is the case, then is there good reason for it, or can I fix it myself by
adding additional vectorizable operations?
I've attached both test case and full output of ftree-vectorized-verbose=9
Best regards
`Allan
#include <stdint.h>
inline uint16_t transsign1(int16_t v) {
// written with no control-flow to facilitate auto-vectorization
uint16_t sv = v >> 15; // signed left-shift gives a classic sign selector -1 or 0
sv = sv & 0x7FFFU; // never invert the sign-bit
return v ^ sv; // conditional invertion by xor
}
inline uint16_t transsign2(int16_t v) {
if (v<0) {
return 0x8000U | ~v;
} else {
return v;
}
}
inline uint16_t transsign3(int16_t v) {
if (v<0) {
return 0x8000U | (1-v);
} else {
return v;
}
}
// candidate for vectorizaton
void convertts1(uint16_t* out, int16_t* in, uint32_t len) {
for(unsigned int i=0;i<len;++i) {
out[i] = transsign1(in[i]);
}
}
// candidate for vectorizaton
void convertts2(uint16_t* out, int16_t* in, uint32_t len) {
for(unsigned int i=0;i<len;++i) {
out[i] = transsign2(in[i]);
}
}
// candidate for vectorizaton
void convertts3(uint16_t* out, int16_t* in, uint32_t len) {
for(unsigned int i=0;i<len;++i) {
out[i] = transsign3(in[i]);
}
}
Attachment:
vectorizesign-debug.txt
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |