[PATCH] D80907: [PowerPC] refactor convertToImmediateForm - NFC

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 2 03:19:16 PDT 2020


shchenz marked an inline comment as done.
shchenz added inline comments.


================
Comment at: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:3421
+    // Set the bits (        MB + 32        ) to (        ME + 32        ).
+    uint64_t Mask = ((1LLU << (32 - MB)) - 1) & ~((1LLU << (31 - ME)) - 1);
+    InVal &= Mask;
----------------
shchenz wrote:
> steven.zhang wrote:
> > It can be improved with APInt utility.
> ```
>  APInt Mask = APInt::getBitsSetWithWrap(32, 32 - ME - 1, 32 - MB);
>  // Current APInt::getBitsSetWithWrap sets all bits to 0 if loBit is equal to highBit.
>  // If MB - ME == 1, we expect a full set mask instead of 0.
>  if (MBSrc - MESrc == 1)
>     Mask.setAllBits();
> ```
> 
> Personally, I think using a raw APInt would be better than above statements?
Should be a raw int... not raw APInt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80907





More information about the llvm-commits mailing list