[Mlir-commits] [mlir] [mlir][ArmSVE] Add convert_to/from_svbool ops (PR #68586)

Benjamin Maxwell llvmlistbot at llvm.org
Wed Oct 11 10:29:01 PDT 2023


================
@@ -481,10 +500,39 @@ class IsScalableVectorOfLengthPred<list<int> allowedLengths> :
                            == }]
                          # allowedlength>)>]>;
 
+// Normalizes an index so it can be bounds checked.
+// Negative values are mapped to their absolute value.
+//  - These are used to index in reverse (i.e. index -1 would be the last element)
+// Positive values are mapped to their value + 1.
+//  - This results the same range of values as the negative indices
+// This allows bounds checking to be: len(list) >= NormalizeIndex<idx>.ret.
+class NormalizeIndex<int value> {
+  int ret = !if(!lt(value, 0), !sub(0, value), !add(value, 1));
+}
----------------
MacDue wrote:

Normalized here means the indices in both directions have the same value. 
I.e. The first element going forwards is index 2, going backwards it's index -3.
So you normalize it so they're both 3.

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


More information about the Mlir-commits mailing list