[llvm] [IR] Change getParamIndexForOptionalMask to assume masked parameter is last (PR #180558)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 10 02:19:44 PST 2026


================
@@ -132,11 +132,10 @@ 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;
+    if (!ParamCount || Shape.Parameters[ParamCount - 1].ParamKind !=
+                           VFParamKind::GlobalPredicate)
+      return std::nullopt;
----------------
david-arm wrote:

Yep, makes sense. I've added some code for debug builds that checks the number of masked parameters and the position.

https://github.com/llvm/llvm-project/pull/180558


More information about the llvm-commits mailing list