[llvm] [SandboxVec][VecUtils] Lane Enumerator (PR #188355)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 30 10:52:20 PDT 2026


================
@@ -304,6 +305,69 @@ class VecUtils {
                                      WhereIt, Ctx, "Unpack");
   }
 
+  /// Iterate over all lanes and Value pairs commulatively.
+  // For example, given a range: {i32 %v0, <2 x i32> %v1, i32 %v2} we get:
+  //  Lane Elm
+  //   0   %v0
+  //   1   %v1
+  //   3   %v2
+  template <typename RangeT, typename RangeIteratorT>
+  class LaneValueEnumerator {
+    const RangeT &Range;
+    /// Cummulative Lane count.
+    unsigned Lane;
+    /// Points to current element.
+    RangeIteratorT It;
+    RangeIteratorT ItE;
+
+  public:
+    LaneValueEnumerator(const RangeT &Range, unsigned Lane, RangeIteratorT It,
----------------
vporpo wrote:

> How about calling the Lane argument something like FirstLane? and maybe add to the class description a couple of words saying it supports starting at a number != 0.

I used `BeginLane` instead to match with `Begin` (which used to be `It`).

> Also the It and ItE argument names don't look very descriptive from the outside. Maybe Begin and End?

Done

I also dropped the `Range` argument, it was only used in the assertion.

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


More information about the llvm-commits mailing list