[Mlir-commits] [mlir] [mlir][tensor] fix out-of-bound index in tensor.dim (PR #85901)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Mar 24 22:12:35 PDT 2024


================
@@ -738,11 +741,11 @@ OpFoldResult DimOp::fold(FoldAdaptor adaptor) {
   if (!tensorType)
     return {};
 
-  // Out of bound indices produce undefined behavior but are still valid IR.
-  // Don't choke on them.
+  // Fold dim to posion if the index is out of bound. Poison represents
+  // undefined behavior.
   int64_t indexVal = index.getInt();
   if (indexVal < 0 || indexVal >= tensorType.getRank())
-    return {};
+    return ub::PoisonAttr::get(getContext());
----------------
lipracer wrote:

After reviewing the design related to Poison semantics, there is no clear definition of the issue of excessive crossing. Can we simply skip folding and do nothing according to the original logic, so as not to disrupt the processing of the original code.

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


More information about the Mlir-commits mailing list