Correctly model undefined behavior in {tensor|memref}.dim
authorSanjoy Das <sanjoy.das@getcruise.com>
Wed, 12 Oct 2022 05:33:45 +0000 (22:33 -0700)
committerSanjoy Das <sanjoy.das@getcruise.com>
Thu, 13 Oct 2022 00:30:13 +0000 (17:30 -0700)
commitadabce41185910227ca276a1cfd22e76443dd238
tree10ae8307847258d694721708e700e95cedbf247a
parent5a52c5c42669b3e547c9ca69b59b560d0268b85c
Correctly model undefined behavior in {tensor|memref}.dim

These operations have undefined behavior if the index is not less than the rank of the source tensor / memref, so they cannot be freely speculated like they were before this patch.  After this patch we speculate them only if we can prove that they don't have UB.

Depends on D135505.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D135748
mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
mlir/test/Transforms/loop-invariant-code-motion.mlir