[llvm] d91b5b0 - [DAG] foldConstantFPMath - use APFloat& for read-only constant fold arg. NFC.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 17 04:34:14 PST 2021


Author: Simon Pilgrim
Date: 2021-12-17T12:34:03Z
New Revision: d91b5b0f57d8b7cd0c05a2103c913aa1844fc667

URL: https://github.com/llvm/llvm-project/commit/d91b5b0f57d8b7cd0c05a2103c913aa1844fc667
DIFF: https://github.com/llvm/llvm-project/commit/d91b5b0f57d8b7cd0c05a2103c913aa1844fc667.diff

LOG: [DAG] foldConstantFPMath - use APFloat& for read-only constant fold arg. NFC.

We just need to copy the 1st arg (which we use for the constant fold result) - use a cheaper const reference for the 2nd arg.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 4339efa98b4c..baa8e641a5fd 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5483,7 +5483,8 @@ SDValue SelectionDAG::foldConstantFPMath(unsigned Opcode, const SDLoc &DL,
   auto *N1CFP = dyn_cast<ConstantFPSDNode>(N1.getNode());
   auto *N2CFP = dyn_cast<ConstantFPSDNode>(N2.getNode());
   if (N1CFP && N2CFP) {
-    APFloat C1 = N1CFP->getValueAPF(), C2 = N2CFP->getValueAPF();
+    APFloat C1 = N1CFP->getValueAPF(); // make copy
+    const APFloat &C2 = N2CFP->getValueAPF();
     switch (Opcode) {
     case ISD::FADD:
       C1.add(C2, APFloat::rmNearestTiesToEven);


        


More information about the llvm-commits mailing list