[llvm] r254242 - [SelectionDAG] Use std::any_of instead of a manually coded loop. NFC

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 29 15:45:32 PST 2015



Craig Topper via llvm-commits wrote:
> Replaced in r254260.
>
> FWIW, there's also this code in ScalarEvolution.cpp that does similar.
>
>    // If FlagNSW is true and all the operands are non-negative, infer FlagNUW.
>    auto IsKnownNonNegative =
>      std::bind(std::mem_fn(&ScalarEvolution::isKnownNonNegative), SE, _1);
>
>    if (SignOrUnsignWrap == SCEV::FlagNSW &&
>        std::all_of(Ops.begin(), Ops.end(), IsKnownNonNegative))
>      Flags =
>          ScalarEvolution::setFlags(Flags, (SCEV::NoWrapFlags)SignOrUnsignMask);

I had added that code some time back, but I agree that a lambda is much more readable.  Fixed in r254276.

-- Sanjoy


>
>
> On Sun, Nov 29, 2015 at 7:20 AM, David Blaikie <dblaikie at gmail.com <mailto:dblaikie at gmail.com>> wrote:
>
>
>     On Nov 29, 2015 3:28 AM, "Alex Bradbury via llvm-commits" <llvm-commits at lists.llvm.org
>     <mailto:llvm-commits at lists.llvm.org>> wrote:
>      >
>      > On 29 November 2015 at 04:37, Craig Topper via llvm-commits
>      > <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
>      > > Author: ctopper
>      > > Date: Sat Nov 28 22:37:11 2015
>      > > New Revision: 254242
>      > >
>      > > URL: http://llvm.org/viewvc/llvm-project?rev=254242&view=rev
>     <http://llvm.org/viewvc/llvm-project?rev=254242&view=rev>
>      > > Log:
>      > > [SelectionDAG] Use std::any_of instead of a manually coded loop. NFC
>      > >
>      > > Modified:
>      > >     llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
>      > >
>      > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
>      > > URL:
>     http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=254242&r1=254241&r2=254242&view=diff
>     <http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=254242&r1=254241&r2=254242&view=diff>
>      > > ==============================================================================
>      > > --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
>      > > +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sat Nov 28 22:37:11 2015
>      > > @@ -11317,15 +11317,11 @@ bool DAGCombiner::MergeConsecutiveStores
>      > >          break;
>      > >      }
>      > >
>      > > -    bool Alias = false;
>      > >      // Check if this store interferes with any of the loads that we found.
>      > > -    for (unsigned ld = 0, lde = AliasLoadNodes.size(); ld < lde; ++ld)
>      > > -      if (isAlias(AliasLoadNodes[ld], StoreNodes[i].MemNode)) {
>      > > -        Alias = true;
>      > > -        break;
>      > > -      }
>      > > -    // We found a load that alias with this store. Stop the sequence.
>      > > -    if (Alias)
>      > > +    // If we find a load that alias with this store. Stop the sequence.
>      > > +    if (std::any_of(AliasLoadNodes.begin(), AliasLoadNodes.end(),
>      > > +                    std::bind(std::mem_fn(&DAGCombiner::isAlias), this,
>      > > +                              std::placeholders::_1, StoreNodes[i].MemNode)))
>      >
>      > I know this comes partly down to personal preference, but I can't help
>      > but think this would be more readable with a lambda (like the recent
>      > cleanups to CodeGenDAGPatterns by you and David Blaikie).
>
>     Yeah, that's what the Google style guide has suggested (that bind just isn't worth it & lambdas should just be used
>     instead, even in the few cases where bind might be lexically shorter) & I tend to agree with it, but not totally
>     fussed, personally, if people want to play with bind and see how it feels
>
>      >
>      > Alex
>      > _______________________________________________
>      > llvm-commits mailing list
>      > llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
>      > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
>
>
> --
> ~Craig
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list