Before we speculatively execute a basic block, query the cost of inserting the necessary select instructions against the phi folding threshold. For non-trivial insertions, a more accurate decision can probably be made during machine if-conversion.
I also don't quite get what this is about. I'd suggest the following:
I guess it's an improvement for ARM, but the cost-modelling still looks bogus to me there.
It defies the point. We should calculate the single total cost of speculation,
and compare it once with the threshold, not compute parts of the cost
and compare them separately with the threshold each time.