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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jamborm at gcc dot gnu.org

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's early SRA dropping alignment info.

-  # .MEM_48 = VDEF <.MEM_47>
-  # lhs access alignment 128+0
-  D.2264.theX = _31;
-  # .MEM_49 = VDEF <.MEM_48>
-  # lhs access alignment 128+32
-  D.2264.theY = _34;
-  # .MEM_50 = VDEF <.MEM_49>
-  # lhs access alignment 128+64
-  D.2264.theZ = _37;
-  # .MEM_51 = VDEF <.MEM_50>
-  # lhs access alignment 128+96
-  D.2264.theT = _40;
-  # .MEM_52 = VDEF <.MEM_51>
-  # lhs access alignment 128+0
-  # rhs access alignment 128+0
-  *res_7(D) = D.2264;
-  # .MEM_9 = VDEF <.MEM_52>
+  SR.22_44 = _31;
+  SR.23_43 = _34;
+  SR.24_42 = _37;
+  SR.25_41 = _40;
+  # .MEM_8 = VDEF <.MEM_1(D)>
+  # lhs access alignment 32+0
+  MEM[(struct LorentzVector *)res_7(D)] = SR.22_44;
+  # .MEM_53 = VDEF <.MEM_8>
+  # lhs access alignment 32+0
+  MEM[(struct LorentzVector *)res_7(D) + 4B] = SR.23_43;
+  # .MEM_54 = VDEF <.MEM_53>
+  # lhs access alignment 32+0
+  MEM[(struct LorentzVector *)res_7(D) + 8B] = SR.24_42;
+  # .MEM_55 = VDEF <.MEM_54>
+  # lhs access alignment 32+0
+  MEM[(struct LorentzVector *)res_7(D) + 12B] = SR.25_41;
+  # .MEM_9 = VDEF <.MEM_55>

of course as it splits up the aggregate store and we can't represent
align + known misalignment with the type used on the MEM_REF we are
somewhat lost here.  We can do better for the first and the third
store though:

  # .MEM_8 = VDEF <.MEM_1(D)>
  # lhs access alignment 128+0
  MEM[(struct LorentzVector *)res_7(D)] = SR.22_44;
  # .MEM_53 = VDEF <.MEM_8>
  # lhs access alignment 32+0
  MEM[(struct LorentzVector *)res_7(D) + 4B] = SR.23_43;
  # .MEM_54 = VDEF <.MEM_53>
  # lhs access alignment 64+0
  MEM[(struct LorentzVector *)res_7(D) + 8B] = SR.24_42;
  # .MEM_55 = VDEF <.MEM_54>
  # lhs access alignment 32+0
  MEM[(struct LorentzVector *)res_7(D) + 12B] = SR.25_41;

that seems to be enough here as the vectorizer is clever enough to only
care about the first ref alignment of a group access.  Phew ;)

Testing

Index: gcc/tree-sra.c
===================================================================
--- gcc/tree-sra.c      (revision 221324)
+++ gcc/tree-sra.c      (working copy)
@@ -1597,7 +1597,7 @@ build_ref_for_offset (location_t loc, tr
   misalign = (misalign + offset) & (align - 1);
   if (misalign != 0)
     align = (misalign & -misalign);
-  if (align < TYPE_ALIGN (exp_type))
+  if (align != TYPE_ALIGN (exp_type))
     exp_type = build_aligned_type (exp_type, align);

   mem_ref = fold_build2_loc (loc, MEM_REF, exp_type, base, off);

Reply via email to