From: Simon Pilgrim Date: Tue, 9 Apr 2019 12:29:26 +0000 (+0000) Subject: [TargetLowering] SimplifyDemandedBits - Remove GetDemandedSrcMask lambda. NFCI. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f312d38896bb30dca2354202516a591f8a003722;p=llvm [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357999 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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; + 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; - } + 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