[flang-commits] [flang] [Flang] Add Maxloc to fir simplify intrinsics pass (PR #75463)
Mats Petersson via flang-commits
flang-commits at lists.llvm.org
Thu Dec 14 09:05:56 PST 2023
================
@@ -751,20 +750,23 @@ static mlir::FunctionType genRuntimeMinlocType(fir::FirOpBuilder &builder,
{boxRefType, boxType, boxType}, {});
}
-static void genRuntimeMinlocBody(fir::FirOpBuilder &builder,
- mlir::func::FuncOp &funcOp, unsigned rank,
- int maskRank, mlir::Type elementType,
- mlir::Type maskElemType,
- mlir::Type resultElemTy) {
- auto init = [](fir::FirOpBuilder builder, mlir::Location loc,
- mlir::Type elementType) {
+static void genRuntimeMinMaxlocBody(fir::FirOpBuilder &builder,
+ mlir::func::FuncOp &funcOp, bool isMax,
+ unsigned rank, int maskRank,
+ mlir::Type elementType,
+ mlir::Type maskElemType,
+ mlir::Type resultElemTy) {
+ auto init = [isMax](fir::FirOpBuilder builder, mlir::Location loc,
+ mlir::Type elementType) {
if (auto ty = elementType.dyn_cast<mlir::FloatType>()) {
const llvm::fltSemantics &sem = ty.getFloatSemantics();
return builder.createRealConstant(
- loc, elementType, llvm::APFloat::getLargest(sem, /*Negative=*/false));
+ loc, elementType, llvm::APFloat::getLargest(sem, /*Negative=*/isMax));
}
unsigned bits = elementType.getIntOrFloatBitWidth();
- int64_t maxInt = llvm::APInt::getSignedMaxValue(bits).getSExtValue();
+ int64_t maxInt = (isMax ? llvm::APInt::getSignedMinValue(bits)
----------------
Leporacanthicus wrote:
The name `maxInt` isn't correct for a value that is `minValue`, right? Maybe `startValue` or `initInt` or something like that? Very nitpicky, I know... :)
https://github.com/llvm/llvm-project/pull/75463
More information about the flang-commits
mailing list