[Bug tree-optimization/123113] factor_out_conditional_operation could be improved to handle `EDGE_COUNT (merge->preds) != 2`
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Dec 13 22:19:21 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123113
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
```
void f(int a, int b, int c, int d, int *e)
{
if (a)
{
if (b){
c = c > d ? c : d;
*e = c;
}
else {
c = c > d ? c : d;
*e = c;
}
}
}
```
cs_elim/cs_elim_limited does not handle the above case either.
It has:
```
/* Only handle sinking of store from 2 bbs only,
The middle bbs don't need to come from the
if always since we are sinking rather than
hoisting. */
if (EDGE_COUNT (bb3->preds) != 2)
return;
...
/* bb1 is the middle block, bb2 the join block, bb the split block,
e1 the fallthrough edge from bb1 to bb2. We can't do the
optimization if the join block has more than two predecessors. */
if (EDGE_COUNT (bb2->preds) > 2)
return;
```
But basically we need to do the split here too.
This is definitely stage 1 material.
More information about the Gcc-bugs
mailing list