[llvm] a1317be - [SelectionDAG] Use std::clamp (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 24 00:23:58 PDT 2022


Author: Kazu Hirata
Date: 2022-10-24T00:23:51-07:00
New Revision: a1317be28d01ed6bbf6d87ed89ab7caabeb42c7e

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

LOG: [SelectionDAG] Use std::clamp (NFC)

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 8967dab250db1..8fa4c85d5f3ad 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -4299,7 +4299,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
 
     // If the sign portion ends in our element the subtraction gives correct
     // result. Otherwise it gives either negative or > bitwidth result
-    return std::max(std::min(KnownSign - rIndex * BitWidth, BitWidth), 0);
+    return std::clamp(KnownSign - rIndex * BitWidth, 0, BitWidth);
   }
   case ISD::INSERT_VECTOR_ELT: {
     // If we know the element index, split the demand between the


        


More information about the llvm-commits mailing list