[llvm] c438b25 - [DAG] GetDemandedBits - don't bother asserting for a non-null cast<> result. NFC.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 04:43:38 PDT 2020


Author: Simon Pilgrim
Date: 2020-06-03T12:43:07+01:00
New Revision: c438b257f19cb4a8adbb8eb377f84b10052ea7c5

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

LOG: [DAG] GetDemandedBits - don't bother asserting for a non-null cast<> result. NFC.

cast<> will assert on failure anyhow.

This lets us fold the cast<> with the getAPIntValue() that uses it.

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 7e1991c866eb..249b662be2a1 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2195,9 +2195,7 @@ SDValue SelectionDAG::GetDemandedBits(SDValue V, const APInt &DemandedBits,
                                                 *this, 0);
     break;
   case ISD::Constant: {
-    auto *CV = cast<ConstantSDNode>(V.getNode());
-    assert(CV && "Const value should be ConstSDNode.");
-    const APInt &CVal = CV->getAPIntValue();
+    const APInt &CVal = cast<ConstantSDNode>(V)->getAPIntValue();
     APInt NewVal = CVal & DemandedBits;
     if (NewVal != CVal)
       return getConstant(NewVal, SDLoc(V), V.getValueType());


        


More information about the llvm-commits mailing list