* [Bug tree-optimization/58039] -ftree-vectorizer makes a loop crash on a non-aligned memory
2013-08-01 4:52 [Bug tree-optimization/58039] New: -ftree-vectorizer make a loop crash on non-aligned memory bar at mariadb dot org
@ 2013-08-06 9:55 ` bar at mariadb dot org
2013-08-07 9:15 ` mikpe at it dot uu.se
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: bar at mariadb dot org @ 2013-08-06 9:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58039
--- Comment #2 from Alexander Barkov <bar at mariadb dot org> ---
Any updates? Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/58039] -ftree-vectorizer makes a loop crash on a non-aligned memory
2013-08-01 4:52 [Bug tree-optimization/58039] New: -ftree-vectorizer make a loop crash on non-aligned memory bar at mariadb dot org
2013-08-06 9:55 ` [Bug tree-optimization/58039] -ftree-vectorizer makes a loop crash on a " bar at mariadb dot org
@ 2013-08-07 9:15 ` mikpe at it dot uu.se
2013-08-12 10:32 ` bar at mariadb dot org
2013-08-12 12:18 ` mikpe at it dot uu.se
3 siblings, 0 replies; 5+ messages in thread
From: mikpe at it dot uu.se @ 2013-08-07 9:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58039
--- Comment #3 from Mikael Pettersson <mikpe at it dot uu.se> ---
Your code performs mis-aligned uint16_t stores, which x86 allows. The
vectorizer turns those into larger and still mis-aligned `movdqa' stores, which
x86 does not allow, hence the SEGV.
Replace the non-portable mis-aligned stores with portable code like
#define int2store_little_endian(s,A) memcpy((s), &(A), 2)
or gcc-specific code like
struct __attribute__((__packed__)) packed_uint16 {
uint16_t u16;
};
#define int2store_little_endian(s,A) ((struct packed_uint16*)(s))->u16 = (A)
and then the vectorizer generates large `movdqu' stores, which is pretty much
the best you can hope for unless you rewrite the code to avoid mis-aligned
stores.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/58039] -ftree-vectorizer makes a loop crash on a non-aligned memory
2013-08-01 4:52 [Bug tree-optimization/58039] New: -ftree-vectorizer make a loop crash on non-aligned memory bar at mariadb dot org
2013-08-06 9:55 ` [Bug tree-optimization/58039] -ftree-vectorizer makes a loop crash on a " bar at mariadb dot org
2013-08-07 9:15 ` mikpe at it dot uu.se
@ 2013-08-12 10:32 ` bar at mariadb dot org
2013-08-12 12:18 ` mikpe at it dot uu.se
3 siblings, 0 replies; 5+ messages in thread
From: bar at mariadb dot org @ 2013-08-12 10:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58039
--- Comment #4 from Alexander Barkov <bar at mariadb dot org> ---
Mikael, thanks for your comment on this.
(In reply to Mikael Pettersson from comment #3)
> Your code performs mis-aligned uint16_t stores, which x86 allows.
Right, this is done for performance purposes.
> The
> vectorizer turns those into larger and still mis-aligned `movdqa' stores,
> which x86 does not allow, hence the SEGV.
Can you please clarify: is it a bug in the recent gcc versions?
Note, we've used such performance improvement tricks for years.
It worked perfectly fine until now.
Has anything changed in how the gcc vectorizer works recently?
>
> Replace the non-portable mis-aligned stores with portable code like
>
> #define int2store_little_endian(s,A) memcpy((s), &(A), 2)
>
> or gcc-specific code like
>
> struct __attribute__((__packed__)) packed_uint16 {
> uint16_t u16;
> };
> #define int2store_little_endian(s,A) ((struct packed_uint16*)(s))->u16 = (A)
>
> and then the vectorizer generates large `movdqu' stores, which is pretty
> much the best you can hope for unless you rewrite the code to avoid
> mis-aligned stores.
Unfortunately it's not possible to avoid mis-aligned stores due to the
project architecture.
I've read somewhere that gcc vectorizer generates two code branches,
for aligned memory and for non-aligned memory (but can't find
the reference now). Can you please confirm this?
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/58039] -ftree-vectorizer makes a loop crash on a non-aligned memory
2013-08-01 4:52 [Bug tree-optimization/58039] New: -ftree-vectorizer make a loop crash on non-aligned memory bar at mariadb dot org
` (2 preceding siblings ...)
2013-08-12 10:32 ` bar at mariadb dot org
@ 2013-08-12 12:18 ` mikpe at it dot uu.se
3 siblings, 0 replies; 5+ messages in thread
From: mikpe at it dot uu.se @ 2013-08-12 12:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58039
--- Comment #5 from Mikael Pettersson <mikpe at it dot uu.se> ---
(In reply to Alexander Barkov from comment #4)
> > The
> > vectorizer turns those into larger and still mis-aligned `movdqa' stores,
> > which x86 does not allow, hence the SEGV.
>
> Can you please clarify: is it a bug in the recent gcc versions?
>
> Note, we've used such performance improvement tricks for years.
> It worked perfectly fine until now.
> Has anything changed in how the gcc vectorizer works recently?
I know next to nothing about the vectorizer, so I cannot comment on this.
> Unfortunately it's not possible to avoid mis-aligned stores due to the
> project architecture.
Mis-aligned accesses are Ok, as long as they are expressed using the proper
mechanisms (memcpy, attribute packed, or pragma packed).
> I've read somewhere that gcc vectorizer generates two code branches,
> for aligned memory and for non-aligned memory (but can't find
> the reference now). Can you please confirm this?
I don't know, see above.
^ permalink raw reply [flat|nested] 5+ messages in thread