This is a follow-up of the patch committed by James at r228826 (see D7506).
Now that SimplifyCFG uses TargetTransformInfo for cost analysis, we have to fix the cost heuristic for intrinsic calls to cttz/ctlz.
Revision r224899 (reviewed here: D6728) added two new hooks to TLI to let targets define whether cttz/ctlz are cheap or not. For example, on x86, ctlz is very expensive if the target doesn't have feature LZCNT.
This patch defines method getIntrinsicCost in BasicTTIImpl: now BasicTTIImpl queries TLI to check how expensive is a call to cttz/ctlz for the target.
I added some test cases in Transforms/SimplifyCFG/X86 to verify that SimplifyCFG only speculates cttz/ctlz when those are "cheap" for the target. I also removed a test case in SimplifyCFG/SpeculativelyExec.ll since it is not profitable to speculate a slow call to cttz even if we pass flag -phi-node-folding-threshold=2 to opt.
Please let me know if ok to submit.
P.s. The long term goal (if possible) is to migrate the logic added in CodeGenPrepare at r224899 into SimplifyCFG.