diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-05-04 04:33:27 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-05-04 04:33:27 +0000 |
commit | d4d09fd73d2cb9e503828ead17401afb446e3ed1 (patch) | |
tree | bbd8f0e05eaead92067e7f866d57077dffe59bd4 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | bdfe90050bcdd0a95d11f55db5deb8818d223b86 (diff) | |
download | bcm5719-llvm-d4d09fd73d2cb9e503828ead17401afb446e3ed1.tar.gz bcm5719-llvm-d4d09fd73d2cb9e503828ead17401afb446e3ed1.zip |
[SelectionDAG] Improve known bits support for CTPOP.
This is based on the same concept from ValueTracking's version of computeKnownBits.
llvm-svn: 302110
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 33b9b333765..efcb6158ed3 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -2376,7 +2376,10 @@ void SelectionDAG::computeKnownBits(SDValue Op, KnownBits &Known, break; } case ISD::CTPOP: { - Known.Zero.setBitsFrom(Log2_32(BitWidth)+1); + computeKnownBits(Op.getOperand(0), Known2, DemandedElts, Depth + 1); + // If we know some of the bits are zero, they can't be one. + unsigned PossibleOnes = BitWidth - Known2.Zero.countPopulation(); + Known.Zero.setBitsFrom(Log2_32(PossibleOnes) + 1); break; } case ISD::LOAD: { |