Open topperc opened 4 years ago
Current Codegen: https://godbolt.org/z/9Gvdh5v1s
We need to decide what is optimal. If we prefer the gcc form when the condition is used to branch, do we also want to do that without a branch? Because gcc doesn't do that currently: https://godbolt.org/z/xarhz6f4a
Extended Description
This code produces suboptimal code with clang
clang:
gcc:
The condition is canonicalized to ctpop(x) == 1 in InstCombine. Then expanded back into two conditionals during SelectionDAG. SelectionDAG doesn't have any optimizations for changing a branch on 2 setccs ored together into separate branches. I'm not sure if we could add that or if we should expand the ctpop in CodeGenPrepare.