[llvm] [SelectionDAG][NFC] Refactor duplicate code into SDNode::bitcastToAPInt() (PR #127503)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 17 07:16:21 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);
       else
         return SDValue();
----------------
arsenm wrote:

Avoid the move and should invert this to early return on failure 

https://github.com/llvm/llvm-project/pull/127503


More information about the llvm-commits mailing list