Skip to content

Commit 1a1a5ec

Browse files
committed
[SDAG] Avoid use of ConstantExpr::getFPTrunc() (NFC)
Use the constant folding API instead. As we're working on ConstantFP, it is guaranteed to succeed.
1 parent 4983432 commit 1a1a5ec

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/ADT/SmallPtrSet.h"
1919
#include "llvm/ADT/SmallSet.h"
2020
#include "llvm/ADT/SmallVector.h"
21+
#include "llvm/Analysis/ConstantFolding.h"
2122
#include "llvm/Analysis/TargetLibraryInfo.h"
2223
#include "llvm/CodeGen/ISDOpcodes.h"
2324
#include "llvm/CodeGen/MachineFunction.h"
@@ -324,7 +325,8 @@ SelectionDAGLegalize::ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP) {
324325
TLI.isLoadExtLegal(ISD::EXTLOAD, OrigVT, SVT) &&
325326
TLI.ShouldShrinkFPConstant(OrigVT)) {
326327
Type *SType = SVT.getTypeForEVT(*DAG.getContext());
327-
LLVMC = cast<ConstantFP>(ConstantExpr::getFPTrunc(LLVMC, SType));
328+
LLVMC = cast<ConstantFP>(ConstantFoldCastOperand(
329+
Instruction::FPTrunc, LLVMC, SType, DAG.getDataLayout()));
328330
VT = SVT;
329331
Extend = true;
330332
}

0 commit comments

Comments
 (0)