[TTI] Teach the cost heuristic how to query TLI to check if a zext/trunc is 'free...
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Thu, 12 Feb 2015 14:17:24 +0000 (14:17 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Thu, 12 Feb 2015 14:17:24 +0000 (14:17 +0000)
commit44926033f61b3927677f280439e530ae86cfea74
treefe615c6a962885652399157556dfb7fc2a5ea328
parentc70b2070db29d4fc3ef11beb7be0ed69ec069d3e
[TTI] Teach the cost heuristic how to query TLI to check if a zext/trunc is 'free' for the target.

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 in TargetTransformInfoImplCRTPBase
would have conservatively returned a 'default' TCC_Basic for all zero-extends,
and TCC_Free for truncates on native types.

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

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

Differential Revision: http://reviews.llvm.org/D7585

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228923 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/TargetTransformInfoImpl.h
include/llvm/CodeGen/BasicTTIImpl.h
test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll