[Bug tree-optimization/105740] missed optimization switch transformation for conditions with duplicate conditions

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jun 21 09:12:54 GMT 2022


--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The problem with switch-conversion done multiple times is that when it is done
early, it can do worse job than when it is done late, e.g. we can have better
range information later which allows (unfortunately switch-conversion doesn't
use that yet, there is a PR about it) to ignore some never reachable values
So ideally we either need to be able to undo switch-conversion and redo it if
things have changed, or do it only late and for e.g. inlining costs perform it
only in analysis mode and record somewhere what kind of lowering would be done
and how much it would cost.
With multiple if-to-switch, don't we risk that we turn some ifs into switch,
switch-conversion lowers it back to ifs and then another if-to-switch matches
it again and again lowers it?

More information about the Gcc-bugs mailing list