From 502506a124bf05445526c87d5f760bef41b97c94 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Tue, 9 Apr 2019 12:29:26 +0000 Subject: [PATCH] [TargetLowering] SimplifyDemandedBits - Remove GetDemandedSrcMask lambda. NFCI. An older version of this could return false but now that this always succeeds we can just inline and simplify it. llvm-svn: 357999 --- lib/CodeGen/SelectionDAG/TargetLowering.cpp | 51 +++++++++------------ 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 114bb1c11f6..ab934d18aee 100644 --- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -1402,37 +1402,30 @@ bool TargetLowering::SimplifyDemandedBits( if (SrcVT.isVector() && NumSrcEltBits > 1 && (BitWidth % NumSrcEltBits) == 0 && TLO.DAG.getDataLayout().isLittleEndian()) { - 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()) { - DemandedSrcBits |= Sub; - for (unsigned j = 0; j != NumElts; ++j) - if (DemandedElts[j]) - DemandedSrcElts.setBit((j * Scale) + i); - } + unsigned Scale = BitWidth / NumSrcEltBits; + unsigned NumSrcElts = SrcVT.getVectorNumElements(); + APInt DemandedSrcBits = APInt::getNullValue(NumSrcEltBits); + APInt DemandedSrcElts = APInt::getNullValue(NumSrcElts); + for (unsigned i = 0; i != Scale; ++i) { + unsigned Offset = i * NumSrcEltBits; + APInt Sub = DemandedBits.extractBits(NumSrcEltBits, Offset); + if (!Sub.isNullValue()) { + DemandedSrcBits |= Sub; + for (unsigned j = 0; j != NumElts; ++j) + if (DemandedElts[j]) + DemandedSrcElts.setBit((j * Scale) + i); } - return true; - }; - - 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; } + + 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