diff options
author | Craig Topper <craig.topper@intel.com> | 2019-02-20 18:45:38 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2019-02-20 18:45:38 +0000 |
commit | f8498a615b8f0b728fcbc227acba3c38e1024e64 (patch) | |
tree | 8c8585b36b8b59d5cc615f70c952af184321d558 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | 13f45590e349ec7378bf3c4b6f95b710277c6b00 (diff) | |
download | bcm5719-llvm-f8498a615b8f0b728fcbc227acba3c38e1024e64.tar.gz bcm5719-llvm-f8498a615b8f0b728fcbc227acba3c38e1024e64.zip |
[X86] Add test case to show missed opportunity to remove an explicit AND on the bit position from BT when it has known zeros.
If the bit position has known zeros in it, then the AND immediate will likely be optimized to remove bits.
This can prevent GetDemandedBits from recognizing that the AND is unnecessary.
llvm-svn: 354498
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index d7d7b8b7191..de69099d03d 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -2102,9 +2102,13 @@ SDValue SelectionDAG::GetDemandedBits(SDValue V, const APInt &Mask) { break; case ISD::AND: { // X & -1 -> X (ignoring bits which aren't demanded). - ConstantSDNode *AndVal = isConstOrConstSplat(V.getOperand(1)); - if (AndVal && Mask.isSubsetOf(AndVal->getAPIntValue())) - return V.getOperand(0); + // Also handle the case where masked out bits in X are known to be zero. + if (ConstantSDNode *RHSC = isConstOrConstSplat(V.getOperand(1))) { + const APInt &AndVal = RHSC->getAPIntValue(); + if (Mask.isSubsetOf(AndVal) || + Mask.isSubsetOf(computeKnownBits(V.getOperand(0)).Zero | AndVal)) + return V.getOperand(0); + } break; } case ISD::ANY_EXTEND: { |