https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116125
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rsandifo at gcc dot gnu.org Target Milestone|--- |12.5 Target|riscv |x86_64-*-* Component|target |tree-optimization Summary|RISC-V: Does not fully |[12/13/14/15 Regression] |checking for overlapping |Does not fully checking for |memory regions |overlapping memory regions Last reconfirmed|2024-07-29 00:00:00 | Keywords| |wrong-code Known to fail|14.1.0 | Priority|P3 |P2 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed, this also fails on x86-64. It works when using unsigned char or unsigned int data and only fails with the bitfield. The bitfield has the effect of aligning num and we get padding. create runtime check for data references _3->D.3529 and _5->D.3529 using an address-based WAR/WAW test t.c:10:21: note: created 1 versioning for alias checks. _39 = b_10(D) + 4; _40 = a_11(D) - _39; _41 = (sizetype) _40; _42 = _41 + 18446744073709551613; // _41 - 3 _18 = 1; if (_42 > 18) goto <bb 17>; [80.00%] $2 = (const dr_with_seg_len_pair_t &) @0x4774088: {first = {dr = 0x48b1610, seg_len = <integer_cst 0x7ffff686b7c8>, access_size = {coeffs = {1}}, align = 4}, second = {dr = 0x48b31a0, seg_len = <integer_cst 0x7ffff686b7c8>, access_size = {coeffs = {1}}, align = 4}, flags = 2} (gdb) p debug_generic_expr (0x7ffff686b7c8) 28 the vectorization factor is 8. Richard, you did create_waw_or_war_checks - can you check? The testcase needs bitfield handling in if-conversion but I suspect we can do without as well. The following fails with GCC 12 already (you might or might not need -fno-vect-cost-model) typedef struct __attribute__((aligned(4))) { unsigned char num; } st; void __attribute__((noipa)) mem_overlap (st *a, st *b) { for (int i = 0; i < 9; i++) a[i].num = b[i].num + 1; } int main () { st * a; a = (st*) __builtin_malloc (9 * sizeof(st)); __builtin_memset (a, 0, 9 * sizeof(st)); // input a = 0, 0, 0, 0, 0, 0, 0, 0, 0 mem_overlap(&a[1], a); // output a = 0, 1, 2, 3, 4, 5, 6, 7, 8 if (a[2].num != 2) __builtin_abort(); return 0; }