[PATCH] [TTI] Teach the cost heuristic how to query TLI to check if a zext/trunc is "free" for the target.

Andrea Di Biagio Andrea_DiBiagio at sn.scee.net
Thu Feb 12 05:26:18 PST 2015


Hi hfinkel, jmolloy,

Now that SimplifyCFG uses TTI for the cost heuristic, we can teach BasicTTIImpl how to query TLI in order to get a more accurate cost for truncates and zero-extends.

Before this patch, the basic cost heuristic (see TargetTransformInfoImplCRTPBase) would have conservatively returned a 'default' TCC_Basic for all zero-extends, and TCC_Free for truncates on native types.

This patch improves that logic so that we query TLI if available to get more accurate answers. If TLI is available, then we know we can call methods 'isZExtFree' and 'isTruncateFree' to check if a zext/trunc is free for the target.

Added more test cases in SimplifyCFG/X86/speculate-cttz-ctlz.ll. With this change, SimplifuCFG is now able to speculate a "cheap" cttz/ctlz immediately followed by a free zext/trunc.

This patch would make redundant the logic originally added in CodeGenPrepare at r225274  (reviewed here: D6853).
I plan to send other patches to remove that logic from CodeGenPrepare.

Please let me know if ok to submit.
Thanks,
Andrea

http://reviews.llvm.org/D7585

Files:
  include/llvm/Analysis/TargetTransformInfoImpl.h
  include/llvm/CodeGen/BasicTTIImpl.h
  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: D7585.19819.patch
Type: text/x-patch
Size: 8422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150212/d17a43ac/attachment.bin>


More information about the llvm-commits mailing list