On Wed, Jan 29, 2025 at 06:46:30PM +0000, Richard Sandiford wrote:
> As Andrew says in the bugzilla comments, this PR is about a case where
> we tried to fuse two stores of x0, one in which x0 was defined and one
> in which it was undefined. merge_access_arrays failed on the conflict,
> but the failure wasn't caught.
>
> Normally the hazard detection code would fail if the instructions
> had incompatible uses. However, an undefined use doesn't impose
> many restrictions on movements. I think this is likely to be the
> only case where hazard detection isn't enough.
>
> As Andrew notes in bugzilla, it might be possible to allow uses
> of defined and undefined values to be merged to the defined value.
> But that sounds dangerous in the general case, as an rtl-ssa-level
> decision. We might run the risk of turning conditional UB into
> unconditional UB. And LLVM proves that the definition of "undef"
> isn't simple.
>
> Tested on aarch64-linux-gnu. OK to install?
>
> Richard
>
>
> gcc/
> PR rtl-optimization/118320
> * pair-fusion.cc (pair_fusion_bb_info::fuse_pair): Commonize
> the merge of input_uses and return early if it fails.
>
> gcc/testsuite/
> PR rtl-optimization/118320
> * g++.dg/torture/pr118320.C: New test.
Ok.
Jakub