[Mlir-commits] [mlir] [MLIR] support dynamic indexing in `VectorEmulateNarrowTypes` (PR #114169)

Han-Chung Wang llvmlistbot at llvm.org
Mon Nov 4 11:13:19 PST 2024


================
@@ -380,25 +433,27 @@ struct ConvertVectorLoad final : OpConversionPattern<vector::LoadOp> {
             ? getConstantIntValue(linearizedInfo.intraDataOffset)
             : 0;
 
-    if (!foldedIntraVectorOffset) {
-      // unimplemented case for dynamic intra vector offset
-      return failure();
-    }
-
+    // always load enough elements which can cover the original elements
+    int64_t maxintraDataOffset =
+        foldedIntraVectorOffset ? *foldedIntraVectorOffset : scale - 1;
----------------
hanhanW wrote:

I recently learned a trick to make it look cleaner. We can use `value_or`. What do you think?

```suggestion
    int64_t maxintraDataOffset = foldedIntraVectorOffset.value_or(scale - 1);
```

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


More information about the Mlir-commits mailing list