Skip to content

Commit a517b83

Browse files
committed
Addressed review comments.
1 parent 56e9d95 commit a517b83

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

flang/lib/Optimizer/CodeGen/CodeGen.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,7 @@ struct CallOpConversion : public fir::FIROpConversion<fir::CallOp> {
596596
auto fmi =
597597
mlir::cast<mlir::LLVM::FastmathFlagsInterface>(llvmCall.getOperation());
598598
if (!fmi.isFastmathApplicable())
599-
llvmCall->setAttr(
600-
mlir::LLVM::CallOp::getFastmathAttrName(),
601-
mlir::LLVM::FastmathFlagsAttr::get(call.getContext(),
602-
mlir::LLVM::FastmathFlags::none));
599+
llvmCall.setFastmathFlags(mlir::LLVM::FastmathFlags::none);
603600
rewriter.replaceOp(call, llvmCall);
604601
return mlir::success();
605602
}

mlir/include/mlir/Dialect/Arith/IR/ArithOps.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,9 +1211,6 @@ def Arith_ExtFOp : Arith_FToFCastOp<"extf", [DeclareOpInterfaceMethods<ArithFast
12111211
The destination type must to be strictly wider than the source type.
12121212
When operating on vectors, casts elementwise.
12131213
}];
1214-
let extraClassDeclaration = [{
1215-
bool isApplicable() { return true; }
1216-
}];
12171214
let hasVerifier = 1;
12181215
let hasFolder = 1;
12191216

mlir/include/mlir/Dialect/Arith/IR/ArithOpsInterfaces.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def ArithFastMathInterface : OpInterface<"ArithFastMathInterface"> {
7373
auto attr = fmi.getFastMathFlagsAttr();
7474
if (attr && attr.getValue() != ::mlir::arith::FastMathFlags::none &&
7575
!fmi.isArithFastMathApplicable())
76-
return $_op->emitOpError() << "FastMathFlagsAttr is not applicable";
76+
return $_op->emitOpError()
77+
<< "has flag(s) `" << stringifyEnum(attr.getValue())
78+
<< "`, but fast-math flags are not applicable "
79+
"(`isArithFastMathApplicable()` returns false)";
7780
return ::mlir::success();
7881
}];
7982
}

mlir/include/mlir/Dialect/LLVMIR/LLVMInterfaces.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def FastmathFlagsInterface : OpInterface<"FastmathFlagsInterface"> {
7373
auto attr = fmi.getFastmathAttr();
7474
if (attr && attr.getValue() != ::mlir::LLVM::FastmathFlags::none &&
7575
!fmi.isFastmathApplicable())
76-
return $_op->emitOpError() << "FastmathFlagsAttr is not applicable";
76+
return $_op->emitOpError()
77+
<< "has flag(s) `" << stringifyEnum(attr.getValue())
78+
<< "`, but fast-math flags are not applicable "
79+
"(`isFastmathApplicable()` returns false)";
7780
return ::mlir::success();
7881
}];
7982
}

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3798,7 +3798,7 @@ bool mlir::LLVM::FastmathFlagsInterface::isCompatibleType(Type type) {
37983798
} else if (auto arrayType = dyn_cast<LLVMArrayType>(type)) {
37993799
do {
38003800
type = arrayType.getElementType();
3801-
} while (arrayType = dyn_cast<LLVMArrayType>(type));
3801+
} while ((arrayType = dyn_cast<LLVMArrayType>(type)));
38023802
}
38033803

38043804
if (isa<FloatType>(type))

mlir/test/Dialect/LLVMIR/invalid.mlir

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,3 +1703,11 @@ llvm.func @wrong_number_of_bundle_tags() {
17031703
} : (i32, i32) -> ()
17041704
llvm.return
17051705
}
1706+
1707+
// -----
1708+
1709+
func.func @call_invalid_fastmath(%callee : !llvm.ptr) {
1710+
// expected-error@+1 {{has flag(s) `nsz, afn`, but fast-math flags are not applicable (`isFastmathApplicable()` returns false)}}
1711+
llvm.call %callee() {fastmathFlags = #llvm.fastmath<nsz,afn>} : !llvm.ptr, () -> i32
1712+
llvm.return
1713+
}

0 commit comments

Comments
 (0)