[PATCH] D147042: [HardwareLoops] Default values

Sam Parker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 28 05:29:24 PDT 2023


samparker created this revision.
samparker added a reviewer: XinWang10.
Herald added a subscriber: hiraditya.
Herald added a project: All.
samparker requested review of this revision.
Herald added a project: LLVM.

Set defaults for CountType and LoopDecrement.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147042

Files:
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/lib/Analysis/TargetTransformInfo.cpp


Index: llvm/lib/Analysis/TargetTransformInfo.cpp
===================================================================
--- llvm/lib/Analysis/TargetTransformInfo.cpp
+++ llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -53,16 +53,6 @@
 };
 } // namespace
 
-bool HardwareLoopInfo::canAnalyze(LoopInfo &LI) {
-  // If the loop has irreducible control flow, it can not be converted to
-  // Hardware loop.
-  LoopBlocksRPO RPOT(L);
-  RPOT.perform(&LI);
-  if (containsIrreducibleCFG<const BasicBlock *>(RPOT, LI))
-    return false;
-  return true;
-}
-
 IntrinsicCostAttributes::IntrinsicCostAttributes(
     Intrinsic::ID Id, const CallBase &CI, InstructionCost ScalarizationCost,
     bool TypeBasedOnly)
@@ -108,6 +98,24 @@
   Arguments.insert(Arguments.begin(), Args.begin(), Args.end());
 }
 
+HardwareLoopInfo::HardwareLoopInfo(Loop *L) : L(L) {
+  // Match default options:
+  // - hardware-loop-counter-bitwidth = 32
+  // - hardware-loop-decrement = 1
+  CountType = Type::getInt32Ty(L->getHeader()->getContext());
+  LoopDecrement = ConstantInt::get(CountType, 1);
+}
+
+bool HardwareLoopInfo::canAnalyze(LoopInfo &LI) {
+  // If the loop has irreducible control flow, it can not be converted to
+  // Hardware loop.
+  LoopBlocksRPO RPOT(L);
+  RPOT.perform(&LI);
+  if (containsIrreducibleCFG<const BasicBlock *>(RPOT, LI))
+    return false;
+  return true;
+}
+
 bool HardwareLoopInfo::isHardwareLoopCandidate(ScalarEvolution &SE,
                                                LoopInfo &LI, DominatorTree &DT,
                                                bool ForceNestedLoop,
Index: llvm/include/llvm/Analysis/TargetTransformInfo.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -95,7 +95,7 @@
 /// Attributes of a target dependent hardware loop.
 struct HardwareLoopInfo {
   HardwareLoopInfo() = delete;
-  HardwareLoopInfo(Loop *L) : L(L) {}
+  HardwareLoopInfo(Loop *L);
   Loop *L = nullptr;
   BasicBlock *ExitBlock = nullptr;
   BranchInst *ExitBranch = nullptr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147042.508968.patch
Type: text/x-patch
Size: 2113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230328/be95b89c/attachment.bin>


More information about the llvm-commits mailing list