https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124006
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |54571, 123113
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2026-02-08
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
On the gimple level in cselim we have
```
# .MEM_17 = VDEF <.MEM_12(D)>
data_16(D)->flags = _8;
if (iftmp.0_10 != 0)
goto <bb 8>; [50.00%]
else
goto <bb 9>; [50.00%]
<bb 8> [local count: 178956971]:
_9 = _8 | 64;
# .MEM_18 = VDEF <.MEM_17>
data_16(D)->flags = _9;
<bb 9> [local count: 1073741824]:
# .MEM_11 = PHI <.MEM_12(D)(5), .MEM_18(8), .MEM_19(6), .MEM_17(7)>
```
First is cselim does not handle the above case.
phiopt4 should handle it too but don't:
```
if (iftmp.0_10 != 0)
goto <bb 9>; [50.00%]
else
goto <bb 8>; [50.00%]
<bb 8> [local count: 178956971]:
# .MEM_17 = VDEF <.MEM_12(D)>
data_16(D)->flags = _8;
goto <bb 10>; [100.00%]
<bb 9> [local count: 178956971]:
_9 = _8 | 64;
# .MEM_18 = VDEF <.MEM_12(D)>
data_16(D)->flags = _9;
<bb 10> [local count: 1073741824]:
# .MEM_11 = PHI <.MEM_12(D)(5), .MEM_18(9), .MEM_19(6), .MEM_17(8)>
```
Both of those is basically PR 123113 I think. sink does not do it either
because there is bb10 would not be correct location to do it but rather an new
bb for joining block from the cond 7 through the 2 bb 8/9.
And then left with PR 54571 .
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54571
[Bug 54571] Missed optimization converting between bit sets
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123113
[Bug 123113] factor_out_conditional_operation could be improved to handle
`EDGE_COUNT (merge->preds) != 2`