[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)
commitb08862c4f0685023dd05ffc3c756aa6a5b50b049
tree019535b463db880b699bd7fe68e653472a489b94
parentfe412882c23fca8424057437c57120f681019543
[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

llvm-svn: 228923
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll