[PATCH] [alpha] adjust MEM alignment for block move [PR115459] (was: Re: [PATCH v2] [PR100106] Reject unaligned subregs when strict alignment is required)

Alexandre Oliva oliva@adacore.com
Thu Jun 13 07:36:44 GMT 2024


Hello, Maciej,

On Jun 12, 2024, "Maciej W. Rozycki" <macro@orcam.me.uk> wrote:

>  This has regressed building the `alpha-linux-gnu' target, in libada, as 
> from commit d6b756447cd5 including GCC 14 and up to current GCC 15 trunk:

> | Error detected around g-debpoo.adb:1896:8                                |

> I have filed PR #115459.

Thanks!

This was tricky to duplicate without access to an alpha-linux-gnu
machine.  I ended up building an uberbaum tree with --disable-shared
--disable-threads --enable-languages=ada up to all-target-libgcc, then I
replaced gcc/collect2 with a wrapper script that dropped crt[1in].o and
-lc, so that link tests in libada/configure would succeed without glibc
for the target.  libada still wouldn't build, because of the missing
glibc headers, but I could compile g-depboo.adb with -I pointing at a
x86_64-linux-gnu's gcc/ada/rts build tree, and with that, at -O2, I
could trigger the problem and investigate it.  And with the following
patch, the problem seems to be gone.

Maciej, would you be so kind as to give it a spin with a native
regstrap?  TIA,

Richard, is this ok to install if regstrapping succeeds?


Before issuing loads or stores for a block move, adjust the MEM
alignments if analysis of the addresses enabled the inference of
stricter alignment.  This ensures that the MEMs are sufficiently
aligned for the corresponding insns, which avoids trouble in case of
e.g. substitutions into SUBREGs.


for  gcc/ChangeLog

	PR target/115459
	* config/alpha/alpha.cc (alpha_expand_block_move): Adjust
	MEMs to match inferred alignment.
---
 gcc/config/alpha/alpha.cc |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gcc/config/alpha/alpha.cc b/gcc/config/alpha/alpha.cc
index 1126cea1f7ba2..e090e74b9d073 100644
--- a/gcc/config/alpha/alpha.cc
+++ b/gcc/config/alpha/alpha.cc
@@ -3820,6 +3820,12 @@ alpha_expand_block_move (rtx operands[])
           else if (a >= 16 && c % 2 == 0)
 	    src_align = 16;
 	}
+
+      if (MEM_P (orig_src) && MEM_ALIGN (orig_src) < src_align)
+	{
+	  orig_src = shallow_copy_rtx (orig_src);
+	  set_mem_align (orig_src, src_align);
+	}
     }
 
   tmp = XEXP (orig_dst, 0);
@@ -3841,6 +3847,12 @@ alpha_expand_block_move (rtx operands[])
           else if (a >= 16 && c % 2 == 0)
 	    dst_align = 16;
 	}
+
+      if (MEM_P (orig_dst) && MEM_ALIGN (orig_dst) < dst_align)
+	{
+	  orig_dst = shallow_copy_rtx (orig_dst);
+	  set_mem_align (orig_dst, dst_align);
+	}
     }
 
   ofs = 0;


-- 
Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
   Free Software Activist                   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive


More information about the Gcc-patches mailing list