SimplifyCFG implements basic jump threading, if a branch is performed on a phi node with constant operands. However, InstCombine canonicalizes such phis to the condition value of a previous branch, if possible. SimplifyCFG does support this as well, but only in the very limited case where the same condition is used in a direct predecessor -- notably, this does not include the common diamond pattern (i.e. two consecutive if/elses on the same condition).
This patch extends the code to look back a limited number of blocks to find a branch on the same value, rather than only looking at the direct predecessor.
There is a branch on %tobool.i.i.i higher up that would get threaded -- as that doesn't seem like the point of the test, I've replaced it with a different condition.