mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 23:24:34 +00:00
propagate IR-level fast-math-flags to DAG nodes (NFC)
This patch adds the minimum plumbing necessary to use IR-level fast-math-flags (FMF) in the backend without actually using them for anything yet. This is a follow-on to: http://reviews.llvm.org/rL235997 ...which split the existing nsw / nuw / exact flags and FMF into their own struct. There are 2 structural changes here: 1. The main diff is that we're preparing to extend the optimization flags to affect more than just binary SDNodes. Eg, IR intrinsics ( https://llvm.org/bugs/show_bug.cgi?id=21290 ) or non-binop nodes that don't even exist in IR such as FMA, FNEG, etc. 2. The other change is that we're actually copying the FP fast-math-flags from the IR instructions to SDNodes. Differential Revision: http://reviews.llvm.org/D8900 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236546 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -2208,6 +2208,8 @@ void SelectionDAGBuilder::visitBinary(const User &I, unsigned OpCode) {
|
||||
bool nuw = false;
|
||||
bool nsw = false;
|
||||
bool exact = false;
|
||||
FastMathFlags FMF;
|
||||
|
||||
if (const OverflowingBinaryOperator *OFBinOp =
|
||||
dyn_cast<const OverflowingBinaryOperator>(&I)) {
|
||||
nuw = OFBinOp->hasNoUnsignedWrap();
|
||||
@ -2217,8 +2219,20 @@ void SelectionDAGBuilder::visitBinary(const User &I, unsigned OpCode) {
|
||||
dyn_cast<const PossiblyExactOperator>(&I))
|
||||
exact = ExactOp->isExact();
|
||||
|
||||
if (const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(&I))
|
||||
FMF = FPOp->getFastMathFlags();
|
||||
|
||||
SDNodeFlags Flags;
|
||||
Flags.setAllowReciprocal(FMF.allowReciprocal());
|
||||
Flags.setExact(exact);
|
||||
Flags.setNoInfs(FMF.noInfs());
|
||||
Flags.setNoNaNs(FMF.noNaNs());
|
||||
Flags.setNoSignedWrap(nsw);
|
||||
Flags.setNoSignedZeros(FMF.noSignedZeros());
|
||||
Flags.setNoUnsignedWrap(nuw);
|
||||
Flags.setUnsafeAlgebra(FMF.unsafeAlgebra());
|
||||
SDValue BinNodeValue = DAG.getNode(OpCode, getCurSDLoc(), Op1.getValueType(),
|
||||
Op1, Op2, nuw, nsw, exact);
|
||||
Op1, Op2, &Flags);
|
||||
setValue(&I, BinNodeValue);
|
||||
}
|
||||
|
||||
@ -2267,8 +2281,12 @@ void SelectionDAGBuilder::visitShift(const User &I, unsigned Opcode) {
|
||||
exact = ExactOp->isExact();
|
||||
}
|
||||
|
||||
SDNodeFlags Flags;
|
||||
Flags.setExact(exact);
|
||||
Flags.setNoSignedWrap(nsw);
|
||||
Flags.setNoUnsignedWrap(nuw);
|
||||
SDValue Res = DAG.getNode(Opcode, getCurSDLoc(), Op1.getValueType(), Op1, Op2,
|
||||
nuw, nsw, exact);
|
||||
&Flags);
|
||||
setValue(&I, Res);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user