diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-05-13 15:51:26 +0000 |
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-05-13 15:51:26 +0000 |
| commit | d3cedee3c609270335f82400999b4fa6ffb2e441 (patch) | |
| tree | 9e1898ad5e156cd6a24765229af50f7c3dae6e75 /llvm/lib/CodeGen/SelectionDAG | |
| parent | c6a6c107428e85f218b4de6fe079c8d380f3a1ef (diff) | |
| download | bcm5719-llvm-d3cedee3c609270335f82400999b4fa6ffb2e441.tar.gz bcm5719-llvm-d3cedee3c609270335f82400999b4fa6ffb2e441.zip | |
[TargetLowering] Add SimplifyDemandedBits support for ZERO_EXTEND_VECTOR_INREG
More work for PR39709.
llvm-svn: 360592
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 89298133a0d..b9ac372bba1 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -1375,6 +1375,30 @@ bool TargetLowering::SimplifyDemandedBits( Known = Known.zext(BitWidth, true /* ExtendedBitsAreKnownZero */); break; } + case ISD::ZERO_EXTEND_VECTOR_INREG: { + // TODO - merge this with ZERO_EXTEND above? + SDValue Src = Op.getOperand(0); + EVT SrcVT = Src.getValueType(); + unsigned InBits = SrcVT.getScalarSizeInBits(); + unsigned InElts = SrcVT.getVectorNumElements(); + + // If we only need the non-extended bits of the bottom element + // then we can just bitcast to the result. + if (DemandedBits.getActiveBits() <= InBits && DemandedElts == 1 && + VT.getSizeInBits() == SrcVT.getSizeInBits() && + TLO.DAG.getDataLayout().isLittleEndian()) + return TLO.CombineTo(Op, TLO.DAG.getBitcast(VT, Src)); + + APInt InDemandedBits = DemandedBits.trunc(InBits); + APInt InDemandedElts = DemandedElts.zextOrSelf(InElts); + if (SimplifyDemandedBits(Src, InDemandedBits, InDemandedElts, Known, TLO, + Depth + 1)) + return true; + assert(!Known.hasConflict() && "Bits known to be one AND zero?"); + assert(Known.getBitWidth() == InBits && "Src width has changed?"); + Known = Known.zext(BitWidth, true /* ExtendedBitsAreKnownZero */); + break; + } case ISD::SIGN_EXTEND: { SDValue Src = Op.getOperand(0); unsigned InBits = Src.getScalarValueSizeInBits(); |

