https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114171

--- Comment #6 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
(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-like
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 == 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);

---


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
---

Reply via email to