This is an archive of the discontinued LLVM Phabricator instance.

[Alignment][NFC] Optimize alignTo
ClosedPublic

Authored by gchatelet on Oct 16 2019, 1:57 AM.

Details

Summary

A small optimization suggested by jakehehrlich@ in D64790.

Diff Detail

Event Timeline

gchatelet created this revision.Oct 16 2019, 1:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 16 2019, 1:57 AM
courbet added inline comments.Oct 16 2019, 2:06 AM
llvm/include/llvm/Support/Alignment.h
174

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

gchatelet updated this revision to Diff 225177.Oct 16 2019, 2:25 AM
gchatelet marked 2 inline comments as done.
  • Address comments
llvm/include/llvm/Support/Alignment.h
174

Good catch.

courbet accepted this revision.Oct 16 2019, 2:34 AM
This revision is now accepted and ready to land.Oct 16 2019, 2:34 AM
This revision was automatically updated to reflect the committed changes.