Skip to content

Commit 2de50fe

Browse files
committed
propagate fast math flags to fptrunc
1 parent 514d845 commit 2de50fe

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3908,11 +3908,15 @@ void SelectionDAGBuilder::visitFPTrunc(const User &I) {
39083908
// FPTrunc is never a no-op cast, no need to check
39093909
SDValue N = getValue(I.getOperand(0));
39103910
SDLoc dl = getCurSDLoc();
3911+
SDNodeFlags Flags;
3912+
if (auto *FPOp = dyn_cast<FPMathOperator>(&I))
3913+
Flags.copyFMF(*FPOp);
39113914
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
39123915
EVT DestVT = TLI.getValueType(DAG.getDataLayout(), I.getType());
39133916
setValue(&I, DAG.getNode(ISD::FP_ROUND, dl, DestVT, N,
39143917
DAG.getTargetConstant(
3915-
0, dl, TLI.getPointerTy(DAG.getDataLayout()))));
3918+
0, dl, TLI.getPointerTy(DAG.getDataLayout())),
3919+
Flags));
39163920
}
39173921

39183922
void SelectionDAGBuilder::visitFPExt(const User &I) {

0 commit comments

Comments
 (0)