[Bug middle-end/94703] Small-sized memcpy leading to unnecessary register spillage unless done through a dummy union

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri May 8 11:19:07 GMT 2020


--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Rainer Orth from comment #7)
> Created attachment 48483 [details]
> 32-bit sparc-sun-solaris2.11 pr94703.c.021t.ssa
> The new testcase FAILs on sparc-sun-solaris2.11 (both 32 and 64-bit):
> +FAIL: gcc.dg/tree-ssa/pr94703.c scan-tree-dump ssa "No longer having
> address taken: r"

Hmm, OK looks like memcpy is not folded, likely because the source is
not known to be appropriately aligned.

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr94703.c
index 7209fa0a4d4..eadea45a32f 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr94703.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr94703.c
@@ -4,6 +4,7 @@
 unsigned int set_lowpart (unsigned int const *X)
   unsigned int r = 0;
+  X = __builtin_assume_aligned (X, sizeof (unsigned int) / 2);
   __builtin_memcpy(&r,X,sizeof (unsigned int) / 2);
   return r;

should fix this.  Can you verify and if so, commit?  Thx.

More information about the Gcc-bugs mailing list