[PATCH] Fold together repeated tests for divisibility by constants

Joerg Sonnenberger joerg at britannica.bec.de
Thu Jul 31 16:58:04 PDT 2014


On Mon, Jul 21, 2014 at 06:55:05PM -0700, Richard Smith wrote:
> Index: include/llvm/ADT/APInt.h
> ===================================================================
> --- include/llvm/ADT/APInt.h	(revision 213404)
> +++ include/llvm/ADT/APInt.h	(working copy)
> @@ -1756,13 +1756,13 @@
>  /// \brief Returns the floor log base 2 of the specified APInt value.
>  inline unsigned logBase2(const APInt &APIVal) { return APIVal.logBase2(); }
>  
> -/// \brief Compute GCD of two APInt values.
> +/// \brief Compute GCD of two unsigned APInt values.
>  ///
>  /// This function returns the greatest common divisor of the two APInt values
>  /// using Euclid's algorithm.
>  ///
>  /// \returns the greatest common divisor of Val1 and Val2
> -APInt GreatestCommonDivisor(const APInt &Val1, const APInt &Val2);
> +APInt GreatestCommonDivisor(APInt Val1, APInt Val2);

Doesn't this create an unnecessary copy in many common cases?

Joerg



More information about the llvm-commits mailing list