[PATCH] D148504: [LoopInfo] SFINAE mechanism for hoist into check
Christian Ulmann via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 23 23:25:07 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdc2b8ae962ff: [LoopInfo] SFINAE mechanism for hoist into check (authored by Dinistro).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148504/new/
https://reviews.llvm.org/D148504
Files:
llvm/include/llvm/Support/GenericLoopInfoImpl.h
mlir/include/mlir/IR/Block.h
Index: mlir/include/mlir/IR/Block.h
===================================================================
--- mlir/include/mlir/IR/Block.h
+++ mlir/include/mlir/IR/Block.h
@@ -351,10 +351,6 @@
void printAsOperand(raw_ostream &os, bool printType = true);
void printAsOperand(raw_ostream &os, AsmState &state);
- /// NOTE: Do not call this function, it is only used to be compatible with the
- /// LLVM loop analysis machinery.
- bool isLegalToHoistInto() const { return false; };
-
private:
/// Pair of the parent object that owns this block and a bit that signifies if
/// the operations within this block have a valid ordering.
Index: llvm/include/llvm/Support/GenericLoopInfoImpl.h
===================================================================
--- llvm/include/llvm/Support/GenericLoopInfoImpl.h
+++ llvm/include/llvm/Support/GenericLoopInfoImpl.h
@@ -171,6 +171,22 @@
ExitEdges.emplace_back(BB, Succ);
}
+namespace detail {
+template <class BlockT>
+using has_hoist_check = decltype(&BlockT::isLegalToHoistInto);
+
+template <class BlockT>
+using detect_has_hoist_check = llvm::is_detected<has_hoist_check, BlockT>;
+
+/// SFINAE functions that dispatch to the isLegalToHoistInto member function or
+/// return false, if it doesn't exist.
+template <class BlockT> bool isLegalToHoistInto(BlockT *Block) {
+ if constexpr (detect_has_hoist_check<BlockT>::value)
+ return Block->isLegalToHoistInto();
+ return false;
+}
+} // namespace detail
+
/// getLoopPreheader - If there is a preheader for this loop, return it. A
/// loop has a preheader if there is only one edge to the header of the loop
/// from outside of the loop and it is legal to hoist instructions into the
@@ -188,7 +204,7 @@
return nullptr;
// Make sure we are allowed to hoist instructions into the predecessor.
- if (!Out->isLegalToHoistInto())
+ if (!detail::isLegalToHoistInto(Out))
return nullptr;
// Make sure there is only one exit out of the preheader.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148504.516279.patch
Type: text/x-patch
Size: 1994 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230424/92f1b653/attachment-0001.bin>
More information about the llvm-commits
mailing list