[PATCH] D46637: [TTI] Add uniform/non-uniform constant Pow2 detection to TargetTransformInfo::getInstructionThroughput

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 15 07:22:54 PDT 2018


ABataev added inline comments.


================
Comment at: lib/Analysis/TargetTransformInfo.cpp:758
+
+    if (auto *Splat = dyn_cast<Constant>(V)->getSplatValue()) {
       OpInfo = TargetTransformInfo::OK_UniformConstantValue;
----------------
I think it is better to move the result of statement from line 777 here rather than perform the same kind of analysis 2 times.


================
Comment at: lib/Analysis/TargetTransformInfo.cpp:760-772
+      if (auto *CI = dyn_cast<ConstantInt>(Splat))
+        if (CI->getValue().isPowerOf2())
+          OpProps = TargetTransformInfo::OP_PowerOf2;
+    } else if (auto *CDS = dyn_cast<ConstantDataSequential>(V)) {
+      OpProps = TargetTransformInfo::OP_PowerOf2;
+      for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
+        if (auto *CI = dyn_cast<ConstantInt>(CDS->getElementAsConstant(i)))
----------------
This analysis should be guarded by the check of the `OVP` parameter if it is `nullptr` or not.


================
Comment at: lib/Analysis/TargetTransformInfo.cpp:765
+      OpProps = TargetTransformInfo::OP_PowerOf2;
+      for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
+        if (auto *CI = dyn_cast<ConstantInt>(CDS->getElementAsConstant(i)))
----------------
The names of the variables should start from the capital letters.


Repository:
  rL LLVM

https://reviews.llvm.org/D46637





More information about the llvm-commits mailing list