[llvm] [IR] Change getParamIndexForOptionalMask to assume masked parameter is last (PR #180558)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 12 06:36:45 PST 2026
================
@@ -132,11 +132,22 @@ struct VFInfo {
/// if any exist.
std::optional<unsigned> getParamIndexForOptionalMask() const {
unsigned ParamCount = Shape.Parameters.size();
- for (unsigned i = 0; i < ParamCount; ++i)
- if (Shape.Parameters[i].ParamKind == VFParamKind::GlobalPredicate)
- return i;
- return std::nullopt;
+#ifndef NDEBUG
+ unsigned NumMaskParams =
+ llvm::count_if(Shape.Parameters, [](const VFParameter &I) {
+ return I.ParamKind == VFParamKind::GlobalPredicate;
+ });
+ assert(NumMaskParams <= 1 && "Unexpected number of mask parameters");
+ assert((!NumMaskParams || Shape.Parameters[ParamCount - 1].ParamKind ==
+ VFParamKind::GlobalPredicate) &&
+ "Mask parameter in unexpected position");
+#endif
+
+ if (!ParamCount || Shape.Parameters[ParamCount - 1].ParamKind !=
----------------
david-arm wrote:
Hope you don't mind, but I think I'd prefer to leave the patch as is for now!
https://github.com/llvm/llvm-project/pull/180558
More information about the llvm-commits
mailing list