summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorShuxin Yang <shuxin.llvm@gmail.com>2012-11-29 19:38:54 +0000
committerShuxin Yang <shuxin.llvm@gmail.com>2012-11-29 19:38:54 +0000
commit84fca61ca5fba5c33a799d9133750b6832ddef7e (patch)
tree59095a7c46e6337324c8b3f534bf514e375a3355 /include
parent73601160486b14711e1c6fdd86481eda9c319e45 (diff)
downloadllvm-84fca61ca5fba5c33a799d9133750b6832ddef7e.tar.gz
llvm-84fca61ca5fba5c33a799d9133750b6832ddef7e.tar.bz2
llvm-84fca61ca5fba5c33a799d9133750b6832ddef7e.tar.xz
rdar://12100355 (part 1)
This revision attempts to recognize following population-count pattern: while(a) { c++; ... ; a &= a - 1; ... }, where <c> and <a>could be used multiple times in the loop body. TODO: On X8664 and ARM, __buildin_ctpop() are not expanded to a efficent instruction sequence, which need to be improved in the following commits. Reviewed by Nadav, really appreciate! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Target/TargetTransformImpl.h2
-rw-r--r--include/llvm/TargetTransformInfo.h17
2 files changed, 18 insertions, 1 deletions
diff --git a/include/llvm/Target/TargetTransformImpl.h b/include/llvm/Target/TargetTransformImpl.h
index 7ea2396076..ad38eaf95f 100644
--- a/include/llvm/Target/TargetTransformImpl.h
+++ b/include/llvm/Target/TargetTransformImpl.h
@@ -26,7 +26,7 @@ class TargetLowering;
/// ScalarTargetTransformInfo interface. Different targets can implement
/// this interface differently.
class ScalarTargetTransformImpl : public ScalarTargetTransformInfo {
-private:
+protected:
const TargetLowering *TLI;
public:
diff --git a/include/llvm/TargetTransformInfo.h b/include/llvm/TargetTransformInfo.h
index 94db490443..dbe35ec4c3 100644
--- a/include/llvm/TargetTransformInfo.h
+++ b/include/llvm/TargetTransformInfo.h
@@ -75,6 +75,18 @@ public:
/// LSR, and LowerInvoke use this interface.
class ScalarTargetTransformInfo {
public:
+ /// PopcntHwSupport - Hardware support for population count. Compared to the
+ /// SW implementation, HW support is supposed to significantly boost the
+ /// performance when the population is dense, and it may or not may degrade
+ /// performance if the population is sparse. A HW support is considered as
+ /// "Fast" if it can outperform, or is on a par with, SW implementaion when
+ /// the population is sparse; otherwise, it is considered as "Slow".
+ enum PopcntHwSupport {
+ None,
+ Fast,
+ Slow
+ };
+
virtual ~ScalarTargetTransformInfo() {}
/// isLegalAddImmediate - Return true if the specified immediate is legal
@@ -122,6 +134,11 @@ public:
virtual bool shouldBuildLookupTables() const {
return true;
}
+
+ /// getPopcntHwSupport - Return hardware support for population count.
+ virtual PopcntHwSupport getPopcntHwSupport(unsigned IntTyWidthInBit) const {
+ return None;
+ }
};
/// VectorTargetTransformInfo - This interface is used by the vectorizers