[VPlan] Move VPRecipeWithIRFlags::getFastMathFlags. (NFCI)

Split off suggested refactoring from D157144. Also adds a assert to make
sure this is only used when OpType is FPMathOp.
This commit is contained in:
Florian Hahn 2023-08-07 12:35:53 +01:00
parent 4d3e917839
commit 0b17e9d285
No known key found for this signature in database
GPG Key ID: 9E54DEA47A8F4434
2 changed files with 16 additions and 12 deletions

View File

@ -948,19 +948,9 @@ public:
return GEPFlags.IsInBounds;
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
FastMathFlags getFastMathFlags() const {
FastMathFlags Res;
Res.setAllowReassoc(FMFs.AllowReassoc);
Res.setNoNaNs(FMFs.NoNaNs);
Res.setNoInfs(FMFs.NoInfs);
Res.setNoSignedZeros(FMFs.NoSignedZeros);
Res.setAllowReciprocal(FMFs.AllowReciprocal);
Res.setAllowContract(FMFs.AllowContract);
Res.setApproxFunc(FMFs.ApproxFunc);
return Res;
}
FastMathFlags getFastMathFlags() const;
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void printFlags(raw_ostream &O) const;
#endif
};

View File

@ -216,6 +216,20 @@ void VPRecipeBase::moveBefore(VPBasicBlock &BB,
insertBefore(BB, I);
}
FastMathFlags VPRecipeWithIRFlags::getFastMathFlags() const {
assert(OpType == OperationType::FPMathOp &&
"recipe doesn't have fast math flags");
FastMathFlags Res;
Res.setAllowReassoc(FMFs.AllowReassoc);
Res.setNoNaNs(FMFs.NoNaNs);
Res.setNoInfs(FMFs.NoInfs);
Res.setNoSignedZeros(FMFs.NoSignedZeros);
Res.setAllowReciprocal(FMFs.AllowReciprocal);
Res.setAllowContract(FMFs.AllowContract);
Res.setApproxFunc(FMFs.ApproxFunc);
return Res;
}
Value *VPInstruction::generateInstruction(VPTransformState &State,
unsigned Part) {
IRBuilderBase &Builder = State.Builder;