[llvm] [SelectionDAG] Detect impossible conditions using known bits analysis (PR #150715)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 28 05:56:05 PDT 2025
================
@@ -13529,6 +13529,78 @@ 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 (ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1)) {
+ const APInt &C1 = N1C->getAPIntValue();
+ KnownBits KnownRHS = KnownBits::makeConstant(C1);
+
+ // Bail out early if RHS is unknown (shouldn't happen for constants)
+ if (KnownRHS.isUnknown())
----------------
RKSimon wrote:
How can KnownBits::makeConstant ever create an unknown? At the very best this should just be an assert but really I don't think it needs to be here at all.
https://github.com/llvm/llvm-project/pull/150715
More information about the llvm-commits
mailing list