[PATCH] D69023: [Alignment][NFC] Optimize alignTo

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 02:08:42 PDT 2019


courbet added inline comments.


================
Comment at: llvm/include/llvm/Support/Alignment.h:174
+  // multiple functions gets inlined.
+  return (Size + value - 1) & -value;
 }
----------------
IIUC, `-value` is just the same as `~(value - 1)`. but only works if the representation two's complement. C++ does not guarantee two's complement. What about using  `~(value - 1)` instead ?

https://godbolt.org/z/8KJBV3


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69023/new/

https://reviews.llvm.org/D69023





More information about the llvm-commits mailing list