Skip to content

Commit 05b4a43

Browse files
committed
propagate fast math flags to fptrunc
1 parent 0cf3397 commit 05b4a43

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
@@ -3923,11 +3923,15 @@ void SelectionDAGBuilder::visitFPTrunc(const User &I) {
39233923
// FPTrunc is never a no-op cast, no need to check
39243924
SDValue N = getValue(I.getOperand(0));
39253925
SDLoc dl = getCurSDLoc();
3926+
SDNodeFlags Flags;
3927+
if (auto *FPOp = dyn_cast<FPMathOperator>(&I))
3928+
Flags.copyFMF(*FPOp);
39263929
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
39273930
EVT DestVT = TLI.getValueType(DAG.getDataLayout(), I.getType());
39283931
setValue(&I, DAG.getNode(ISD::FP_ROUND, dl, DestVT, N,
39293932
DAG.getTargetConstant(
3930-
0, dl, TLI.getPointerTy(DAG.getDataLayout()))));
3933+
0, dl, TLI.getPointerTy(DAG.getDataLayout())),
3934+
Flags));
39313935
}
39323936

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

0 commit comments

Comments
 (0)