https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107372
Bug ID: 107372 Summary: Loop distribution create memcpy between structs with different storage order Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: krebbel at gcc dot gnu.org Target Milestone: --- For t.c with "gcc -O3 t.c": struct L { unsigned int val[256]; } __attribute__((scalar_storage_order ("little-endian"))); struct B { unsigned int val[256]; } __attribute__((scalar_storage_order ("big-endian"))); void foo (struct L *restrict l, struct B *restrict b) { int i; for (i = 0; i < 256; i++) l->val[i] = b->val[i]; } The loop distribution pass currently generates a memcpy although it recognizes correctly that both sides of the assignment have different storage order: Analyzing # of iterations of loop 1 exit condition [255, + , 4294967295] != 0 bounds on difference of bases: -255 ... -255 result: # of iterations 255, bounded by 255 Creating dr for *b_5(D).val[i_11] analyze_innermost: t.c:16:23: missed: failed: reverse storage order. ... void foo (struct L * restrict l, struct B * restrict b) { int i; <bb 2> [local count: 10737416]: __builtin_memcpy (l_6(D), b_5(D), 1024); return; }