[llvm] [VPlan] Add vputils::recipesOnly that returns a downcasted range (NFC) (PR #222770)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 00:00:04 PDT 2026
================
@@ -166,6 +166,15 @@ inline VPRecipeBase *findRecipe(VPValue *Start, PredT Pred) {
return nullptr;
}
+/// Returns an iterator range over \p Range which only includes \p RecipeTy
+/// recipes. The accesses are casted to \p RecipeTy.
+template <typename RecipeTy, typename T> auto recipesOnly(T &&Range) {
+ auto Filter = make_filter_range(std::forward<T>(Range),
+ [](auto &R) { return isa<RecipeTy>(R); });
+ return map_range(Filter,
+ [](auto &R) -> RecipeTy & { return cast<RecipeTy>(R); });
----------------
artagnon wrote:
> I don't think we're calling to_vector anywhere.
Right, I meant that a hypothetical?
> map_range just lazily calls the function on each element without any extra storage IIUC.
Yep, I think so: same story with make_filter_range -- it's a lot of template magic, and from memory, chaining too many of them would result in a compiler crash, due to a hard maximum-depth-of-templates-limit?
https://github.com/llvm/llvm-project/pull/222770
More information about the llvm-commits
mailing list