[flang-commits] [flang] [flang] Support non-index shape/shift/slice for CG box operations. (PR #124625)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Tue Jan 28 09:37:29 PST 2025
================
@@ -1675,22 +1675,26 @@ struct EmboxCommonConversion : public fir::FIROpConversion<OP> {
this->attachTBAATag(storeOp, boxTy, boxTy, nullptr);
return storage;
}
-};
-/// Compute the extent of a triplet slice (lb:ub:step).
-static mlir::Value
-computeTripletExtent(mlir::ConversionPatternRewriter &rewriter,
- mlir::Location loc, mlir::Value lb, mlir::Value ub,
- mlir::Value step, mlir::Value zero, mlir::Type type) {
- mlir::Value extent = rewriter.create<mlir::LLVM::SubOp>(loc, type, ub, lb);
- extent = rewriter.create<mlir::LLVM::AddOp>(loc, type, extent, step);
- extent = rewriter.create<mlir::LLVM::SDivOp>(loc, type, extent, step);
- // If the resulting extent is negative (`ub-lb` and `step` have different
- // signs), zero must be returned instead.
- auto cmp = rewriter.create<mlir::LLVM::ICmpOp>(
- loc, mlir::LLVM::ICmpPredicate::sgt, extent, zero);
- return rewriter.create<mlir::LLVM::SelectOp>(loc, cmp, extent, zero);
-}
+ /// Compute the extent of a triplet slice (lb:ub:step).
+ mlir::Value computeTripletExtent(mlir::ConversionPatternRewriter &rewriter,
+ mlir::Location loc, mlir::Value lb,
+ mlir::Value ub, mlir::Value step,
+ mlir::Value zero, mlir::Type type) const {
+ lb = this->integerCast(loc, rewriter, type, lb);
----------------
vzakhari wrote:
`integerCast` is protected within `ConvertFIRToLLVMPattern`, so either `this->` or `FIROpConversion::` should be used. I chose the former :)
https://github.com/llvm/llvm-project/pull/124625
More information about the flang-commits
mailing list