[llvm] r302334 - [SCEV] Use std::move to avoid some APInt copies.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon May 8 10:19:35 PDT 2017


Is it useful to std::move both sides of a binary operator like that? Or is
it equivalent/enough to move only the LHS?

I mean I can appreciate the symmetry too, but it strikes me when reading it
as surprising "wait, is there something weird going on that this could use
both left and right data"?

I guess maybe it can take memory from either if one has a larger internal
buffer?

On Fri, May 5, 2017 at 10:36 PM Craig Topper via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: ctopper
> Date: Sat May  6 00:22:56 2017
> New Revision: 302334
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302334&view=rev
> Log:
> [SCEV] Use std::move to avoid some APInt copies.
>
> Modified:
>     llvm/trunk/lib/Analysis/ScalarEvolution.cpp
>
> Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=302334&r1=302333&r2=302334&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
> +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Sat May  6 00:22:56 2017
> @@ -2970,7 +2970,7 @@ static const APInt gcd(const SCEVConstan
>    else if (ABW < BBW)
>      A = A.zext(BBW);
>
> -  return APIntOps::GreatestCommonDivisor(A, B);
> +  return APIntOps::GreatestCommonDivisor(std::move(A), std::move(B));
>  }
>
>  /// Get a canonical unsigned division expression, or something simpler if
> @@ -8980,7 +8980,7 @@ bool ScalarEvolution::doesIVOverflowOnLT
>                                  .getSignedMax();
>
>      // SMaxRHS + SMaxStrideMinusOne > SMaxValue => overflow!
> -    return (MaxValue - MaxStrideMinusOne).slt(MaxRHS);
> +    return (std::move(MaxValue) -
> std::move(MaxStrideMinusOne)).slt(MaxRHS);
>    }
>
>    APInt MaxRHS = getUnsignedRange(RHS).getUnsignedMax();
> @@ -8989,7 +8989,7 @@ bool ScalarEvolution::doesIVOverflowOnLT
>                                .getUnsignedMax();
>
>    // UMaxRHS + UMaxStrideMinusOne > UMaxValue => overflow!
> -  return (MaxValue - MaxStrideMinusOne).ult(MaxRHS);
> +  return (std::move(MaxValue) - std::move(MaxStrideMinusOne)).ult(MaxRHS);
>  }
>
>  bool ScalarEvolution::doesIVOverflowOnGT(const SCEV *RHS, const SCEV
> *Stride,
> @@ -9006,7 +9006,7 @@ bool ScalarEvolution::doesIVOverflowOnGT
>                                 .getSignedMax();
>
>      // SMinRHS - SMaxStrideMinusOne < SMinValue => overflow!
> -    return (MinValue + MaxStrideMinusOne).sgt(MinRHS);
> +    return (std::move(MinValue) +
> std::move(MaxStrideMinusOne)).sgt(MinRHS);
>    }
>
>    APInt MinRHS = getUnsignedRange(RHS).getUnsignedMin();
> @@ -9015,7 +9015,7 @@ bool ScalarEvolution::doesIVOverflowOnGT
>                              .getUnsignedMax();
>
>    // UMinRHS - UMaxStrideMinusOne < UMinValue => overflow!
> -  return (MinValue + MaxStrideMinusOne).ugt(MinRHS);
> +  return (std::move(MinValue) + std::move(MaxStrideMinusOne)).ugt(MinRHS);
>  }
>
>  const SCEV *ScalarEvolution::computeBECount(const SCEV *Delta, const SCEV
> *Step,
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170508/eda60968/attachment.html>


More information about the llvm-commits mailing list