Currently when a select has a constant value in one branch and the select feeds a conditional branch (via a compare/ phi and compare) we unfold the select statement. This results in threading the conditional branch later on. Similar opportunity exists when a select (with a constant in one branch) feeds a switch (via a phi node). The patch unfolds select under this condition. A testcase is provided.
The patch is tested on two out of tree targets with internal benchmarks and also with testsuite on X86. There are several cases where this code unfolds a select in testsuite (when testing on X86) but none resulted in performance improvement or degradation.
This should probably be written as: