When expanding an aggregate copy into a memcpy call RTL expansion
uses mark_addressable to ensure the base object is addressable but
that function doesn't handle TARGET_MEM_REF bases.  Fixed as follows.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

2022-03-31  Richard Biener  <rguent...@suse.de>

        PR rtl-optimization/105091
        * gimple-expr.cc (mark_addressable): Handle TARGET_MEM_REF
        bases.
---
 gcc/gimple-expr.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-expr.cc b/gcc/gimple-expr.cc
index f9a650b5daf..5faaf43eaf5 100644
--- a/gcc/gimple-expr.cc
+++ b/gcc/gimple-expr.cc
@@ -910,7 +910,8 @@ mark_addressable (tree x)
     x = TREE_OPERAND (x, 0);
   while (handled_component_p (x))
     x = TREE_OPERAND (x, 0);
-  if (TREE_CODE (x) == MEM_REF
+  if ((TREE_CODE (x) == MEM_REF
+       || TREE_CODE (x) == TARGET_MEM_REF)
       && TREE_CODE (TREE_OPERAND (x, 0)) == ADDR_EXPR)
     x = TREE_OPERAND (TREE_OPERAND (x, 0), 0);
   if (!VAR_P (x)
-- 
2.34.1

Reply via email to