https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121881
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The problem is in cond_if_else_store_replacement_1 which just does:
lhs = gimple_assign_lhs (then_assign);
if (!is_gimple_reg_type (TREE_TYPE (lhs))
|| !operand_equal_p (lhs, gimple_assign_lhs (else_assign), 0))
return false;
The issue is we need something more complex than operand_equal_p to handle
this.
Part of the code from
https://gcc.gnu.org/pipermail/gcc-patches/2025-September/694801.html should be
used here too.
The only difference is the types should be compatiable at the end, though I
have to figure out which reference to be used here because they might have
different aliasing sets ....