public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98317] New: Vector Extensions aligned(1) not generating unaligned loads/stores
@ 2020-12-16 11:30 danielhanchen at gmail dot com
2020-12-16 11:34 ` [Bug c++/98317] " danielhanchen at gmail dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: danielhanchen at gmail dot com @ 2020-12-16 11:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98317
Bug ID: 98317
Summary: Vector Extensions aligned(1) not generating unaligned
loads/stores
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: danielhanchen at gmail dot com
Target Milestone: ---
The ordering of aligned(1) causes GCC to generate movaps / movups.
typedef float float128_tv1 __attribute__ ((aligned(1), vector_size(16)));
typedef float float128_tv2 __attribute__ ((vector_size(16), aligned(1)));
float128_tv1 provides MOVAPS
float128_tv2 provides MOVUPS
It seems like the ordering of the arguments changes the assembly.
https://gcc.godbolt.org/z/5qs7e7
It seems like GCC 10.2 and 9.2 all have this issue.
Unless if this was already documentated, this issue can cause massive issues if
memory is unaligned and an aligned load/store is used instead.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/98317] Vector Extensions aligned(1) not generating unaligned loads/stores
2020-12-16 11:30 [Bug c++/98317] New: Vector Extensions aligned(1) not generating unaligned loads/stores danielhanchen at gmail dot com
@ 2020-12-16 11:34 ` danielhanchen at gmail dot com
2020-12-16 12:22 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: danielhanchen at gmail dot com @ 2020-12-16 11:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98317
Daniel Han-Chen <danielhanchen at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |danielhanchen at gmail dot com
--- Comment #1 from Daniel Han-Chen <danielhanchen at gmail dot com> ---
https://gcc.godbolt.org/z/sGWevT
I also tried separating the __attribute__s
typedef float float128_tv1 __attribute__ ((aligned(1), vector_size(16)));
typedef float float128_tv2 __attribute__ ((vector_size(16), aligned(1)));
typedef float float128_tv3 __attribute__((aligned(1))) __attribute__
((vector_size(16)));
typedef float float128_tv4 __attribute__ ((vector_size(16)))
__attribute__((aligned(1)));
aligned as the first argument still fails.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/98317] Vector Extensions aligned(1) not generating unaligned loads/stores
2020-12-16 11:30 [Bug c++/98317] New: Vector Extensions aligned(1) not generating unaligned loads/stores danielhanchen at gmail dot com
2020-12-16 11:34 ` [Bug c++/98317] " danielhanchen at gmail dot com
@ 2020-12-16 12:22 ` jakub at gcc dot gnu.org
2020-12-16 12:30 ` danielhanchen at gmail dot com
2020-12-18 9:11 ` danielhanchen at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-16 12:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98317
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I'm not convinced it is a bug. Because vector_size by definition increases the
alignment, say if you have vector_size on int, the vector type doesn't have
alignof(int) alignment, but alignment of the vector type.
Similarly, if one uses
typedef int T __attribute__((aligned (1)));
typedef T V __attribute__((vector_size (16)));
I'd argue that V should have still 16-byte alignment.
Having the attributes on the same typedef or on the same type is a grey area,
but what we do currently matches what is done with the separate typedefs.
I'd strongly suggest to use separate typedefs, i.e. one that makes a vector
type
typedef float V __attribute__((vector_size (16)));
and then another one that makes it unaligned:
typedef V U __attribute__((aligned (1)));
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/98317] Vector Extensions aligned(1) not generating unaligned loads/stores
2020-12-16 11:30 [Bug c++/98317] New: Vector Extensions aligned(1) not generating unaligned loads/stores danielhanchen at gmail dot com
2020-12-16 11:34 ` [Bug c++/98317] " danielhanchen at gmail dot com
2020-12-16 12:22 ` jakub at gcc dot gnu.org
@ 2020-12-16 12:30 ` danielhanchen at gmail dot com
2020-12-18 9:11 ` danielhanchen at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: danielhanchen at gmail dot com @ 2020-12-16 12:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98317
--- Comment #3 from Daniel Han-Chen <danielhanchen at gmail dot com> ---
Oh ok then.
It's cause I was trying to do unaligned loads by following:
https://stackoverflow.com/questions/9318115/loading-data-for-gccs-vector-extensions
In it, it mentioned using typedef char __attribute__ ((vector_size (16),aligned
(1))) unaligned_byte16, which works, though the other way does not.
But I like your solution by declaring the type as aligned(1) separately.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/98317] Vector Extensions aligned(1) not generating unaligned loads/stores
2020-12-16 11:30 [Bug c++/98317] New: Vector Extensions aligned(1) not generating unaligned loads/stores danielhanchen at gmail dot com
` (2 preceding siblings ...)
2020-12-16 12:30 ` danielhanchen at gmail dot com
@ 2020-12-18 9:11 ` danielhanchen at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: danielhanchen at gmail dot com @ 2020-12-18 9:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98317
Daniel Han-Chen <danielhanchen at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |WORKSFORME
Status|UNCONFIRMED |RESOLVED
--- Comment #4 from Daniel Han-Chen <danielhanchen at gmail dot com> ---
Jakub mentioned his solution, so all good now.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-12-18 9:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16 11:30 [Bug c++/98317] New: Vector Extensions aligned(1) not generating unaligned loads/stores danielhanchen at gmail dot com
2020-12-16 11:34 ` [Bug c++/98317] " danielhanchen at gmail dot com
2020-12-16 12:22 ` jakub at gcc dot gnu.org
2020-12-16 12:30 ` danielhanchen at gmail dot com
2020-12-18 9:11 ` danielhanchen at gmail dot com
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).