[llvm] [IR] Store fast-math flags in subclasses of Instruction (PR #191190)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 13 01:09:08 PDT 2026
================
@@ -284,54 +289,63 @@ class FPMathOperator : public Operator {
public:
/// Test if this operation allows all non-strict floating-point transforms.
bool isFast() const {
- return ((SubclassOptionalData & FastMathFlags::AllowReassoc) != 0 &&
- (SubclassOptionalData & FastMathFlags::NoNaNs) != 0 &&
- (SubclassOptionalData & FastMathFlags::NoInfs) != 0 &&
- (SubclassOptionalData & FastMathFlags::NoSignedZeros) != 0 &&
- (SubclassOptionalData & FastMathFlags::AllowReciprocal) != 0 &&
- (SubclassOptionalData & FastMathFlags::AllowContract) != 0 &&
- (SubclassOptionalData & FastMathFlags::ApproxFunc) != 0);
+ unsigned short FMFValue = getFMFValue();
+ return ((FMFValue & FastMathFlags::AllowReassoc) != 0 &&
+ (FMFValue & FastMathFlags::NoNaNs) != 0 &&
+ (FMFValue & FastMathFlags::NoInfs) != 0 &&
+ (FMFValue & FastMathFlags::NoSignedZeros) != 0 &&
+ (FMFValue & FastMathFlags::AllowReciprocal) != 0 &&
+ (FMFValue & FastMathFlags::AllowContract) != 0 &&
+ (FMFValue & FastMathFlags::ApproxFunc) != 0);
}
/// Test if this operation may be simplified with reassociative transforms.
bool hasAllowReassoc() const {
- return (SubclassOptionalData & FastMathFlags::AllowReassoc) != 0;
+ unsigned short FMFValue = getFMFValue();
+ return (FMFValue & FastMathFlags::AllowReassoc) != 0;
----------------
aengelke wrote:
The refactoring away from SubclassOptionalData to a wrapper function (why not use getFastMathFlags() here?) could be done as a separate PR before this.
https://github.com/llvm/llvm-project/pull/191190
More information about the llvm-commits
mailing list