[llvm] 1a1a5ec - [SDAG] Avoid use of ConstantExpr::getFPTrunc() (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 6 06:55:32 PST 2023
Author: Nikita Popov
Date: 2023-11-06T15:55:23+01:00
New Revision: 1a1a5ec7566c23f080530e45e29d6cffa33b6020
URL: https://github.com/llvm/llvm-project/commit/1a1a5ec7566c23f080530e45e29d6cffa33b6020
DIFF: https://github.com/llvm/llvm-project/commit/1a1a5ec7566c23f080530e45e29d6cffa33b6020.diff
LOG: [SDAG] Avoid use of ConstantExpr::getFPTrunc() (NFC)
Use the constant folding API instead. As we're working on
ConstantFP, it is guaranteed to succeed.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 82751a442dbc3bc..ad5a4506efbd828 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -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"
@@ -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;
}
More information about the llvm-commits
mailing list