[llvm] [SelectionDAG][NFC] Refactor duplicate code into SDNode::bitcastToAPInt() (PR #127503)
    Craig Topper via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Feb 17 10:22:08 PST 2025
    
    
  
================
@@ -27420,10 +27420,8 @@ SDValue DAGCombiner::XformToShuffleWithZero(SDNode *N) {
       }
 
       APInt Bits;
-      if (auto *Cst = dyn_cast<ConstantSDNode>(Elt))
-        Bits = Cst->getAPIntValue();
-      else if (auto *CstFP = dyn_cast<ConstantFPSDNode>(Elt))
-        Bits = CstFP->getValueAPF().bitcastToAPInt();
+      if (auto OptBits = Elt->bitcastToAPInt())
+        Bits = *std::move(OptBits);
----------------
topperc wrote:
Shouldn't this be std::move(*OptBits)? You want to move the APInt inside the optional.
https://github.com/llvm/llvm-project/pull/127503
    
    
More information about the llvm-commits
mailing list