public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61292] New: auto keyword to vector reference generates wrong alignment move
@ 2014-05-23 10:05 vincenzo.innocente at cern dot ch
2014-05-25 12:19 ` [Bug c++/61292] auto keyword to vector reference generates wrong alignment move (causing runtime segfault) vincenzo.innocente at cern dot ch
2021-07-28 16:09 ` [Bug c++/61292] auto keyword to " pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2014-05-23 10:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61292
Bug ID: 61292
Summary: auto keyword to vector reference generates wrong
alignment move
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vincenzo.innocente at cern dot ch
given
typedef float __attribute__( ( vector_size( 16 ) ) ) float32x4_t;
typedef float __attribute__( ( vector_size( 16 ) , aligned(4) ) )
float32x4a4_t;
void add11(float * x, float y, float32x4_t v) {
auto & k1 = *(float32x4a4_t*)(x);
auto & k2 = *(float32x4a4_t*)(x);
k1 +=v;
k2 += k1+v;
}
void add98(float * x, float y, float32x4_t v) {
float32x4a4_t & k1 = *(float32x4a4_t*)(x);
float32x4a4_t & k2 = *(float32x4a4_t*)(x);
k1 +=v;
k2 += k1+v;
}
I get
c++ -std=c++1y -Ofast -march=haswell -S extNotAlign.cc; cat extNotAlign.s
__Z5add11PffU8__vectorf:
LFB4:
vaddps (%rdi), %xmm1, %xmm0
vaddps %xmm0, %xmm0, %xmm0
vaddps %xmm1, %xmm0, %xmm1
vmovaps %xmm1, (%rdi)
ret
LFE4:
.section __TEXT,__text_cold,regular,pure_instructions
LCOLDE4:
.text
LHOTE4:
.section __TEXT,__text_cold,regular,pure_instructions
LCOLDB5:
.text
LHOTB5:
.align 4,0x90
.globl __Z5add98PffU8__vectorf
__Z5add98PffU8__vectorf:
LFB5:
vaddps (%rdi), %xmm1, %xmm0
vaddps %xmm0, %xmm0, %xmm0
vaddps %xmm1, %xmm0, %xmm1
vmovups %xmm1, (%rdi)
ret
second of course is correct (vmovups not vmovaps)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/61292] auto keyword to vector reference generates wrong alignment move (causing runtime segfault)
2014-05-23 10:05 [Bug c++/61292] New: auto keyword to vector reference generates wrong alignment move vincenzo.innocente at cern dot ch
@ 2014-05-25 12:19 ` vincenzo.innocente at cern dot ch
2021-07-28 16:09 ` [Bug c++/61292] auto keyword to " pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2014-05-25 12:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61292
vincenzo Innocente <vincenzo.innocente at cern dot ch> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|auto keyword to vector |auto keyword to vector
|reference generates wrong |reference generates wrong
|alignment move |alignment move (causing
| |runtime segfault)
--- Comment #1 from vincenzo Innocente <vincenzo.innocente at cern dot ch> ---
interesting enough
void add14(float * x, float y, float32x4_t v) {
decltype(auto) k1 = *(float32x4a4_t*)(x);
decltype(auto) k2 = *(float32x4a4_t*)(x);
k1 +=v;
k2 += k1+v;
}
generates
__Z5add14PffU8__vectorf:
LFB5:
vaddps (%rdi), %xmm1, %xmm0
vaddps %xmm0, %xmm0, %xmm0
vaddps %xmm1, %xmm0, %xmm1
vmovups %xmm1, (%rdi)
ret
so c++11 auto is loosing the alignment...
is this "standard" or bug?
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/61292] auto keyword to reference generates wrong alignment move (causing runtime segfault)
2014-05-23 10:05 [Bug c++/61292] New: auto keyword to vector reference generates wrong alignment move vincenzo.innocente at cern dot ch
2014-05-25 12:19 ` [Bug c++/61292] auto keyword to vector reference generates wrong alignment move (causing runtime segfault) vincenzo.innocente at cern dot ch
@ 2021-07-28 16:09 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-28 16:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61292
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-07-28
Status|UNCONFIRMED |NEW
Summary|auto keyword to vector |auto keyword to reference
|reference generates wrong |generates wrong alignment
|alignment move (causing |move (causing runtime
|runtime segfault) |segfault)
Ever confirmed|0 |1
Keywords| |wrong-code
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is unrelated to vector_size attribute even.
Take:
typedef float float32x4_t;
typedef float __attribute__( ( aligned(1) ) ) float32x4a4_t;
void add11(float32x4a4_t * x, float y, float32x4_t v) {
auto & k1 = *(float32x4a4_t*)(x);
auto & k2 = *(float32x4a4_t*)(x);
k1 +=v;
k2 += k1+v;
}
void add98(float32x4a4_t * x, float y, float32x4_t v) {
float32x4a4_t & k1 = *(float32x4a4_t*)(x);
float32x4a4_t & k2 = *(float32x4a4_t*)(x);
k1 +=v;
k2 += k1+v;
}
------ CUT -----
With aarch64 at -O2 -mstrict-align, we get float loads/stores for add11 but
correctly get the byte loads/stores for add98.
Note I notice clang gets this wrong too.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-28 16:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-23 10:05 [Bug c++/61292] New: auto keyword to vector reference generates wrong alignment move vincenzo.innocente at cern dot ch
2014-05-25 12:19 ` [Bug c++/61292] auto keyword to vector reference generates wrong alignment move (causing runtime segfault) vincenzo.innocente at cern dot ch
2021-07-28 16:09 ` [Bug c++/61292] auto keyword to " pinskia at gcc dot gnu.org
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).