[llvm] r309653 - [MathExtras] Remove unnecessary cast of a constant 1 in a subtract.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 21:18:35 PDT 2017


Author: ctopper
Date: Mon Jul 31 21:18:34 2017
New Revision: 309653

URL: http://llvm.org/viewvc/llvm-project?rev=309653&view=rev
Log:
[MathExtras] Remove unnecessary cast of a constant 1 in a subtract.

Pretty sure this will automatically promoted to match the type of the other operand of the subtract. There's plenty of other similar code around here without this cast.

Modified:
    llvm/trunk/include/llvm/Support/MathExtras.h

Modified: llvm/trunk/include/llvm/Support/MathExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=309653&r1=309652&r2=309653&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MathExtras.h (original)
+++ llvm/trunk/include/llvm/Support/MathExtras.h Mon Jul 31 21:18:34 2017
@@ -424,7 +424,7 @@ constexpr inline bool isPowerOf2_32(uint
 
 /// Return true if the argument is a power of two > 0 (64 bit edition.)
 constexpr inline bool isPowerOf2_64(uint64_t Value) {
-  return Value && !(Value & (Value - int64_t(1L)));
+  return Value && !(Value & (Value - 1));
 }
 
 /// Return a byte-swapped representation of the 16-bit argument.




More information about the llvm-commits mailing list