Skip to content

Commit

Permalink
[SDAG] Avoid use of ConstantExpr::getFPTrunc() (NFC)
Browse files Browse the repository at this point in the history
Use the constant folding API instead. As we're working on
ConstantFP, it is guaranteed to succeed.
  • Loading branch information
nikic committed Nov 6, 2023
1 parent 4983432 commit 1a1a5ec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/MachineFunction.h"
Expand Down Expand Up @@ -324,7 +325,8 @@ SelectionDAGLegalize::ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP) {
TLI.isLoadExtLegal(ISD::EXTLOAD, OrigVT, SVT) &&
TLI.ShouldShrinkFPConstant(OrigVT)) {
Type *SType = SVT.getTypeForEVT(*DAG.getContext());
LLVMC = cast<ConstantFP>(ConstantExpr::getFPTrunc(LLVMC, SType));
LLVMC = cast<ConstantFP>(ConstantFoldCastOperand(
Instruction::FPTrunc, LLVMC, SType, DAG.getDataLayout()));
VT = SVT;
Extend = true;
}
Expand Down

0 comments on commit 1a1a5ec

Please sign in to comment.