public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-11266] d: Fix gdc -O2 -mavx generates misaligned vmovdqa instruction [PR114171] Date: Sun, 3 Mar 2024 01:39:07 +0000 (GMT) [thread overview] Message-ID: <20240303013908.42EB9385840E@sourceware.org> (raw) https://gcc.gnu.org/g:3e60064a03a1a6d38ceb5ca4eb7e1f4d30a8aed1 commit r11-11266-g3e60064a03a1a6d38ceb5ca4eb7e1f4d30a8aed1 Author: Iain Buclaw <ibuclaw@gdcproject.org> Date: Sun Mar 3 02:26:37 2024 +0100 d: Fix gdc -O2 -mavx generates misaligned vmovdqa instruction [PR114171] PR d/114171 gcc/d/ChangeLog: * d-codegen.cc (lower_struct_comparison): Keep alignment of original type in reinterpret cast for comparison. gcc/testsuite/ChangeLog: * gdc.dg/torture/pr114171.d: New test. (cherry picked from commit 623f52775e677bb3d6e9e7ef97196741dd904b1e) Diff: --- gcc/d/d-codegen.cc | 1 + gcc/testsuite/gdc.dg/torture/pr114171.d | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index e51e686e3c0..e917a606642 100644 --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -993,6 +993,7 @@ lower_struct_comparison (tree_code code, StructDeclaration *sd, if (tmode == NULL_TREE) tmode = make_unsigned_type (GET_MODE_BITSIZE (mode.require ())); + tmode = build_aligned_type (tmode, TYPE_ALIGN (stype)); t1ref = build_vconvert (tmode, t1ref); t2ref = build_vconvert (tmode, t2ref); diff --git a/gcc/testsuite/gdc.dg/torture/pr114171.d b/gcc/testsuite/gdc.dg/torture/pr114171.d new file mode 100644 index 00000000000..0f9ffcab916 --- /dev/null +++ b/gcc/testsuite/gdc.dg/torture/pr114171.d @@ -0,0 +1,29 @@ +// { dg-do run } +// { dg-additional-options "-mavx" { target avx_runtime } } +// { dg-skip-if "needs gcc/config.d" { ! d_runtime } } +import gcc.builtins; + +struct S1 +{ + string label; +} + +struct S2 +{ + ulong pad; + S1 label; +} + +pragma(inline, false) +auto newitem() +{ + void *p = __builtin_malloc(S2.sizeof); + __builtin_memset(p, 0, S2.sizeof); + return cast(S2*) p; +} + +int main() +{ + auto bn = newitem(); + return bn.label is S1.init ? 0 : 1; +}
reply other threads:[~2024-03-03 1:39 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240303013908.42EB9385840E@sourceware.org \ --to=ibuclaw@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).