https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128236
liu zhenyu <lzy20000419 at outlook dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
--- Comment #1 from liu zhenyu <lzy20000419 at outlook dot com> ---
Before forwprop1 (ccp1 dump, 14.2 -O1):
```
<bb 2> :
c_8 = *p_7(D);
<bb 3> :
# r_1(ab) = PHI <0.0(2), r_2(ab)(4)>
_setjmp (&jb);
...
<bb 4> :
# r_2(ab) = PHI <r_1(ab)(3), r_1(ab)(5), r_11(ab)(6)>
.ABNORMAL_DISPATCHER (0);
...
<bb 6> :
r_11(ab) = REALPART_EXPR <c_8>;
use (r_11(ab));
```
After forwprop1:
```
<bb 2> :
r_11(ab) = REALPART_EXPR <*p_7(D)>;
<bb 3> :
# r_1(ab) = PHI <0.0(2), r_2(ab)(4)>
_setjmp (&jb);
...
<bb 5> :
use (r_1(ab));
<bb 6> :
use (r_11(ab));
```
The definition of r_11(ab) is moved up to the load in bb 2, so it is now live
across the setjmp at the same time as r_1(ab). Both are in the abnormal PHI and
must coalesce, which is no longer possible.
The code is the complex-load rewrite in pass_forwprop::execute
(gcc/tree-ssa-forwprop.cc, master 1e578c16e98e, lines 6880-6943, "Rewrite loads
used only in real/imagpart extractions to component-wise loads"). It builds a
new REALPART_EXPR/IMAGPART_EXPR load with each use's lhs and inserts it before
the original load (line 6936, `gsi_insert_before (&gsi, new_stmt,
GSI_SAME_STMT)`). The use check loop (around line 6895) does not look at the
use's lhs.
optimize_vector_load does the same kind of move for BIT_FIELD_REF uses, and the
PR125502 fix added this check there (line 5809):
```c
/* For alias reasons we move the use to the place of the
load. Avoid this when abnormals are involved. */
|| ((TREE_CODE ((use_lhs = gimple_assign_lhs (use_stmt)))
== SSA_NAME)
&& SSA_NAME_OCCURS_IN_ABNORMAL_PHI (use_lhs)))
```
Possible fix: add the same check to the complex case, i.e. set rewrite = false
when the use's lhs is an SSA_NAME with SSA_NAME_OCCURS_IN_ABNORMAL_PHI. Another
option is to insert the new load at the use instead of at the original load,
but that needs the right vuse there.
Disclaimer: This test case was generated by a fuzzer, and the report was
written with LLM assistance.