[PATCH] [TTI] improved cost heuristic for cttz/ctlz calls.

Andrea Di Biagio Andrea_DiBiagio at sn.scee.net
Wed Feb 11 05:50:24 PST 2015


Hi hfinkel, jmolloy,

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.

http://reviews.llvm.org/D7554

Files:
  include/llvm/CodeGen/BasicTTIImpl.h
  test/Transforms/SimplifyCFG/SpeculativeExec.ll
  test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7554.19744.patch
Type: text/x-patch
Size: 6947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150211/3e1dde38/attachment.bin>


More information about the llvm-commits mailing list