[Mlir-commits] [mlir] [mlir][SCF] Avoid generating unnecessary div/rem operations during coalescing (PR #91562)
Quinn Dawkins
llvmlistbot at llvm.org
Thu May 9 06:47:33 PDT 2024
================
@@ -562,19 +575,43 @@ static Value getProductOfIntsOrIndexes(RewriterBase &rewriter, Location loc,
static std::pair<SmallVector<Value>, SmallPtrSet<Operation *, 2>>
delinearizeInductionVariable(RewriterBase &rewriter, Location loc,
Value linearizedIv, ArrayRef<Value> ubs) {
- Value previous = linearizedIv;
SmallVector<Value> delinearizedIvs(ubs.size());
SmallPtrSet<Operation *, 2> preservedUsers;
- for (unsigned i = 0, e = ubs.size(); i < e; ++i) {
- unsigned idx = ubs.size() - i - 1;
- if (i != 0) {
+
+ llvm::BitVector isUbOne(ubs.size());
+ for (auto [index, ub] : llvm::enumerate(ubs)) {
+ auto ubCst = getConstantIntValue(ub);
+ if (ubCst && ubCst.value() == 1)
+ isUbOne.set(index);
+ }
----------------
qedawkins wrote:
Are the upper bounds already normalized to unit step and zero lower bound by this point?
https://github.com/llvm/llvm-project/pull/91562
More information about the Mlir-commits
mailing list