From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8FB7C3858C31; Fri, 1 Mar 2024 14:13:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8FB7C3858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709302386; bh=9r8BOB6F4f9Czd6um28Pg1OafTmOAQkjA0KaoCOvQAQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hXdtdoY3OekRTTZvmN2J5i7GIKIs9od8LDe2PO7Y+yHm4EmjLgA0tvvxg9I5m45mk wGKhA2n1JdcS0C9lxukV51/HIJHvlNdJXCyJdVR4so8iRSYNJgSSkgo+sLdbooI61z vWwhy5t36nZ6ObRBXqvG8FFOY0WqNT+By0wq9bEg= From: "ibuclaw at gdcproject dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug d/114171] [13/14 Regression] gdc -O2 -mavx generates misaligned vmovdqa instruction Date: Fri, 01 Mar 2024 14:13:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: d X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ibuclaw at gdcproject dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ibuclaw at gdcproject dot org X-Bugzilla-Target-Milestone: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114171 --- Comment #6 from Iain Buclaw --- (In reply to Richard Biener from comment #5) > Unless gdc somehow guarantees bn->label and init are 128bit aligned > then "casting" this way is broken. You can of course use > build_aligned_type to build a properly (mis-)aligned type to use > to dereference to. Right, it looks like the lowering for struct comparisons wasn't taking the original alignment into account when doing identity comparisons of struct-l= ike fields. --- --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -1006,6 +1006,7 @@ lower_struct_comparison (tree_code code, StructDeclaration *sd, if (tmode =3D=3D NULL_TREE) tmode =3D make_unsigned_type (GET_MODE_BITSIZE (mode.require ())); + tmode =3D build_aligned_type (tmode, TYPE_ALIGN (stype)); t1ref =3D build_vconvert (tmode, t1ref); t2ref =3D build_vconvert (tmode, t2ref); --- The above change gets reflected in the generated assembly. --- @@ -326,7 +326,7 @@ _Dmain: subq $8, %rsp .cfi_def_cfa_offset 16 call _D8pr1141718newclassFNbNiZPSQBa14BreakStatement - vmovdqa 8(%rax), %xmm0 + vmovdqu 8(%rax), %xmm0 xorl %eax, %eax vptest %xmm0, %xmm0 sete %al ---=