https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125683
Bug ID: 125683
Summary: possible wrong code due to ce1 combining 2 loads of
different incompatible aliasing sets
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: alias, wrong-code
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take (for LP64 targets, ILP32 has a similar thing for long and int):
```
long f(int a, void *cc)
{
long long c;
if (a)
c = *(long*)cc;
else
c = *(long long*)cc;
return c;
}
```
Before ce1 we have:
```
(note 9 8 10 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
(insn 10 9 13 3 (set (reg/v:DI 101 [ <retval> ])
(mem:DI (reg/v/f:DI 103 [ cc ]) [2 MEM[(long int *)cc_4(D)]+0 S8 A64]))
"/app/example.cpp":5:7 106 {*movdi_aarch64}
(expr_list:REG_DEAD (reg/v/f:DI 103 [ cc ])
(nil)))
(code_label 13 10 14 4 2 (nil) [1 uses])
(note 14 13 15 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(insn 15 14 20 4 (set (reg/v:DI 101 [ <retval> ])
(mem:DI (reg/v/f:DI 103 [ cc ]) [1 MEM[(long long int *)cc_4(D)]+0 S8
A64])) "/app/example.cpp":7:7 106 {*movdi_aarch64}
(expr_list:REG_DEAD (reg/v/f:DI 103 [ cc ])
(nil)))
(code_label 20 15 23 5 1 (nil) [0 uses])
```
But afterwards the we get just have:
```
(insn 35 4 21 2 (set (reg/v:DI 101 [ <retval> ])
(mem:DI (reg/v/f:DI 103 [ cc ]) [1 MEM[(long long int *)cc_4(D)]+0 S8
A64])) "/app/example.cpp":5:7 106 {*movdi_aarch64}
(nil))
```
Note the two aliasing sets are 1 and 2 both are incompatible and only 1 is
chosen here.
I have not found a testcase which this could cause wrong code but I suspect
there could be one somewhere.
I found this while reviewing
https://gcc.gnu.org/pipermail/gcc-patches/2026-June/719780.html .