[llvm] [SelectionDAG] Detect impossible conditions using known bits analysis (PR #150715)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 25 16:02:13 PDT 2025


================
@@ -13529,6 +13529,58 @@ SDValue DAGCombiner::visitSETCC(SDNode *N) {
   SDValue N0 = N->getOperand(0), N1 = N->getOperand(1);
   SDLoc DL(N);
 
+  // Detect impossible conditions using known bits analysis.
+  if (N1.getOpcode() == ISD::Constant) {
+    ConstantSDNode *N1C = cast<ConstantSDNode>(N1);
+    APInt C1 = N1C->getAPIntValue();
----------------
topperc wrote:

getAPIntValue returns a const reference. Do we need to make a copy of it?

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


More information about the llvm-commits mailing list