If EarlyCSE has proved that branch condition is true/false, it can replace it with unconditional branch to the corresponding block.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
EarlyCSE is supposed to preserve the CFG (calls setPreservesCFG, depends on DomTree/MemorySSA etc.), so you can't replace a conditional branch with an unconditional branch. Replacing the value of the condition with "true" or "false" is fine, though.
Why do we want to do this specifically for branches, as opposed to doing it for any instruction where we can prove an operand is constant?
Comment Actions
Need a more general solution regarding scope, and also need to avoid breaking CFG. I will do it in a separate patch using another approach later.