diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-04-09 10:27:59 +0000 |
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-04-09 10:27:59 +0000 |
| commit | 345eacd5552d7294261f9ec248e6cfde58c02cf0 (patch) | |
| tree | 764f117961a4509d7cd0919cfccdb0b3c7bc4240 /llvm/lib/CodeGen/SelectionDAG | |
| parent | fa3eb1201089acf682c63f27d210bd6998c1fe9e (diff) | |
| download | bcm5719-llvm-345eacd5552d7294261f9ec248e6cfde58c02cf0.tar.gz bcm5719-llvm-345eacd5552d7294261f9ec248e6cfde58c02cf0.zip | |
[TargetLowering] SimplifyDemandedBits - call SimplifyDemandedBits in bitcast handling
When bitcasting from a source op to a larger bitwidth op, split the demanded bits and OR them on top of one another and demand those merged bits in the SimplifyDemandedBits call on the source op.
llvm-svn: 357992
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 89d9a55c3f7..114bb1c11f6 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -1395,36 +1395,46 @@ bool TargetLowering::SimplifyDemandedBits( } } - // If bitcast from a vector, see if we can use SimplifyDemandedVectorElts by - // demanding the element if any bits from it are demanded. + // Bitcast from a vector using SimplifyDemanded Bits/VectorElts. + // Demand the elt/bit if any of the original elts/bits are demanded. // TODO - bigendian once we have test coverage. // TODO - bool vectors once SimplifyDemandedVectorElts has SETCC support. if (SrcVT.isVector() && NumSrcEltBits > 1 && (BitWidth % NumSrcEltBits) == 0 && TLO.DAG.getDataLayout().isLittleEndian()) { - auto GetDemandedSrcMask = [&](APInt &DemandedSrcElts) -> bool { + auto GetDemandedSrcMask = [&](APInt &DemandedSrcBits, + APInt &DemandedSrcElts) -> bool { unsigned Scale = BitWidth / NumSrcEltBits; unsigned NumSrcElts = SrcVT.getVectorNumElements(); + DemandedSrcBits = APInt::getNullValue(NumSrcEltBits); DemandedSrcElts = APInt::getNullValue(NumSrcElts); for (unsigned i = 0; i != Scale; ++i) { unsigned Offset = i * NumSrcEltBits; APInt Sub = DemandedBits.extractBits(NumSrcEltBits, Offset); - if (!Sub.isNullValue()) + if (!Sub.isNullValue()) { + DemandedSrcBits |= Sub; for (unsigned j = 0; j != NumElts; ++j) if (DemandedElts[j]) DemandedSrcElts.setBit((j * Scale) + i); + } } return true; }; - APInt DemandedSrcElts; - if (GetDemandedSrcMask(DemandedSrcElts)) { + APInt DemandedSrcBits, DemandedSrcElts; + if (GetDemandedSrcMask(DemandedSrcBits, DemandedSrcElts)) { APInt KnownSrcUndef, KnownSrcZero; if (SimplifyDemandedVectorElts(Src, DemandedSrcElts, KnownSrcUndef, KnownSrcZero, TLO, Depth + 1)) return true; + + KnownBits KnownSrcBits; + if (SimplifyDemandedBits(Src, DemandedSrcBits, DemandedSrcElts, + KnownSrcBits, TLO, Depth + 1)) + return true; } } + // If this is a bitcast, let computeKnownBits handle it. Only do this on a // recursive call where Known may be useful to the caller. if (Depth > 0) { |

