Skip to content

Commit e6395db

Browse files
committed
[SelectionDAG] Remove redundant KnownBits smin and smax operations
It turns out that if any of the operations can be zero, and neither of the operands can be proven to be positive, it is possible for smax to be zero, and KnownBits cannot prove otherwise even with KnownBits::smax. In fact, proving it based on the KnownBits itself at that point without increasing the depth is actually, provably impossible. Same with smin. This covers all the possible cases and is proven to be complete.
1 parent 48324f0 commit e6395db

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5399,9 +5399,6 @@ bool SelectionDAG::isKnownNeverZero(SDValue Op, unsigned Depth) const {
53995399
if (Op1.isNonZero() && Op0.isNonZero())
54005400
return true;
54015401

5402-
if (KnownBits::smax(Op0, Op1).isNonZero())
5403-
return true;
5404-
54055402
return isKnownNeverZero(Op.getOperand(1), Depth + 1) &&
54065403
isKnownNeverZero(Op.getOperand(0), Depth + 1);
54075404
}
@@ -5417,9 +5414,6 @@ bool SelectionDAG::isKnownNeverZero(SDValue Op, unsigned Depth) const {
54175414
if (Op1.isNonZero() && Op0.isNonZero())
54185415
return true;
54195416

5420-
if (KnownBits::smin(Op0, Op1).isNonZero())
5421-
return true;
5422-
54235417
return isKnownNeverZero(Op.getOperand(1), Depth + 1) &&
54245418
isKnownNeverZero(Op.getOperand(0), Depth + 1);
54255419
}

0 commit comments

Comments
 (0)