[PATCH] D76348: [Alignment][NFC] Deprecate getMaxAlignment

Guillaume Chatelet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 18 06:30:28 PDT 2020


gchatelet marked 3 inline comments as done.
gchatelet added inline comments.


================
Comment at: llvm/lib/Target/Mips/MipsSEFrameLowering.cpp:542
       Register VR = MF.getRegInfo().createVirtualRegister(RC);
-      assert(isInt<16>(MFI.getMaxAlignment()) &&
+      assert((Log2(MFI.getMaxAlign()) < 16) &&
              "Function's alignment size requirement is not supported.");
----------------
courbet wrote:
> why `Log2` ?
 - `isInt<N>` from documentation `Checks if an integer fits into the given bit width.`
 - `MFI.getMaxAlign()` is an `Align` which by definition is `2^N`

So testing if a power of two fits into 16 bits is equivalent to testing if its log2 is less than 16 (the maximum power of 2 fitting in 16 bits is `0b1000000000000000`, its log2 is 15)

This is also faster as `.value()` (in [MachineFrameInfo](https://github.com/llvm/llvm-project/blob/db31e2e1e6cacb31f3fe5a9b0e9e52cd626b5ff2/llvm/include/llvm/CodeGen/MachineFrameInfo.h#L586)) will generate the [value from a shift](https://github.com/llvm/llvm-project/blob/a8901a035441de54131407cad579fe3de8a0ea43/llvm/include/llvm/Support/Alignment.h#L86), where `Log2` is a [noop](https://github.com/llvm/llvm-project/blob/a8901a035441de54131407cad579fe3de8a0ea43/llvm/include/llvm/Support/Alignment.h#L225).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76348





More information about the llvm-commits mailing list