[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Oct 7 08:30:43 PDT 2005
Changes in directory llvm/lib/CodeGen/SelectionDAG:
DAGCombiner.cpp updated: 1.20 -> 1.21
---
Log message:
implement CodeGen/PowerPC/div-2.ll:test2-4 by propagating zero bits through
C-X's
---
Diffs of the changes: (+18 -0)
DAGCombiner.cpp | 18 ++++++++++++++++++
1 files changed, 18 insertions(+)
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.20 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.21
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.20 Fri Oct 7 01:10:46 2005
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Oct 7 10:30:32 2005
@@ -205,6 +205,24 @@
return MaskedValueIsZero(Op.getOperand(0), NewVal, TLI);
}
return false;
+ case ISD::SUB:
+ if (ConstantSDNode *CLHS = dyn_cast<ConstantSDNode>(Op.getOperand(0))) {
+ // We know that the top bits of C-X are clear if X contains less bits
+ // than C (i.e. no wrap-around can happen). For example, 20-X is
+ // positive if we can prove that X is >= 0 and < 16.
+ unsigned Bits = MVT::getSizeInBits(CLHS->getValueType(0));
+ if ((CLHS->getValue() & (1 << (Bits-1))) == 0) { // sign bit clear
+ unsigned NLZ = CountLeadingZeros_64(CLHS->getValue()+1);
+ uint64_t MaskV = (1ULL << (63-NLZ))-1;
+ if (MaskedValueIsZero(Op.getOperand(1), ~MaskV, TLI)) {
+ // High bits are clear this value is known to be >= C.
+ unsigned NLZ2 = CountLeadingZeros_64(CLHS->getValue());
+ if ((Mask & ((1ULL << (64-NLZ2))-1)) == 0)
+ return true;
+ }
+ }
+ }
+ break;
case ISD::CTTZ:
case ISD::CTLZ:
case ISD::CTPOP:
More information about the llvm-commits
mailing list