The order that we try various folds within SimplifyCFG can affect the result as shown by this patch that only moves a block of code.
But I'm not sure if the existing code or the diff in the motivating case from PR32078 is valid. Is it safe to convert this chain of branches into bitwise logic? What if the branch conditions are poison?
If this is ok, then we should be able to turn the entire sequence into logic ops rather than select at the end. I haven't looked to see why that still happens. If this is not ok, then we already have a bug in SimplifyCFG.