https://gcc.gnu.org/g:a8db0601be315849a70358333013ef7dffa7a800

commit r17-4540-ga8db0601be315849a70358333013ef7dffa7a800
Author: Eric Botcazou <[email protected]>
Date:   Mon Sep 21 23:44:19 2026 +0200

    Fix wrong optimization of non-byte-aligned array component with -O2
    
    The -ftree-loop-distribute-patterns pass may generate calls to memcpy whose
    source is an array component that is not byte aligned.  This prevents the
    loops from being considered for such a generation as soon as they contain
    a data reference that is not addressable.
    
    gcc/
            * tree-loop-distribution.cc (loop_distribution::classify_partition):
            Disqualify the partition for builtins it it contains nonaddressable
            data references.

Diff:
---
 gcc/tree-loop-distribution.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc
index dff8b72e40be..f7c68defcf17 100644
--- a/gcc/tree-loop-distribution.cc
+++ b/gcc/tree-loop-distribution.cc
@@ -1921,6 +1921,7 @@ loop_distribution::classify_partition (loop_p loop,
 
   /* Perform general partition disqualification for builtins.  */
   if (volatiles_p
+      || has_nonaddressable_dataref_p
       || !flag_tree_loop_distribute_patterns)
     return has_reduction;

Reply via email to