summaryrefslogtreecommitdiff
path: root/flang/lib/Optimizer/Builder/MutableBox.cpp
diff options
context:
space:
mode:
authorMingming Liu <mingmingl@google.com>2025-09-10 15:25:31 -0700
committerGitHub <noreply@github.com>2025-09-10 15:25:31 -0700
commit1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch)
tree57f4b1f313c8cf74eed8819870f39c36ea263c68 /flang/lib/Optimizer/Builder/MutableBox.cpp
parent898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff)
parentb8cefcb601ddaa18482555c4ff363c01a270c2fe (diff)
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
Diffstat (limited to 'flang/lib/Optimizer/Builder/MutableBox.cpp')
-rw-r--r--flang/lib/Optimizer/Builder/MutableBox.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/flang/lib/Optimizer/Builder/MutableBox.cpp b/flang/lib/Optimizer/Builder/MutableBox.cpp
index 50c945df5b46..d4cdfecd0b08 100644
--- a/flang/lib/Optimizer/Builder/MutableBox.cpp
+++ b/flang/lib/Optimizer/Builder/MutableBox.cpp
@@ -603,21 +603,23 @@ void fir::factory::associateMutableBoxWithRemap(
mlir::ValueRange lbounds, mlir::ValueRange ubounds) {
// Compute new extents
llvm::SmallVector<mlir::Value> extents;
- auto idxTy = builder.getIndexType();
+ mlir::Type idxTy = builder.getIndexType();
+ mlir::Value zero = builder.createIntegerConstant(loc, idxTy, 0);
if (!lbounds.empty()) {
auto one = builder.createIntegerConstant(loc, idxTy, 1);
for (auto [lb, ub] : llvm::zip(lbounds, ubounds)) {
- auto lbi = builder.createConvert(loc, idxTy, lb);
- auto ubi = builder.createConvert(loc, idxTy, ub);
- auto diff = mlir::arith::SubIOp::create(builder, loc, idxTy, ubi, lbi);
+
+ mlir::Value lbi = builder.createConvert(loc, idxTy, lb);
+ mlir::Value ubi = builder.createConvert(loc, idxTy, ub);
extents.emplace_back(
- mlir::arith::AddIOp::create(builder, loc, idxTy, diff, one));
+ fir::factory::computeExtent(builder, loc, lbi, ubi, zero, one));
}
} else {
// lbounds are default. Upper bounds and extents are the same.
- for (auto ub : ubounds) {
- auto cast = builder.createConvert(loc, idxTy, ub);
- extents.emplace_back(cast);
+ for (mlir::Value ub : ubounds) {
+ mlir::Value cast = builder.createConvert(loc, idxTy, ub);
+ extents.emplace_back(
+ fir::factory::genMaxWithZero(builder, loc, cast, zero));
}
}
const auto newRank = extents.size();