[PATCH] D33715: [PPC] exploit rotate-left-then-mask-insert instructions for bitfield insert

Hiroshi Inoue via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 29 04:50:39 PST 2017


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


================
Comment at: lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.h:63
+template <typename T>
+static inline bool isRunOfOnes(T Val, unsigned &MB, unsigned &ME) {
+  static_assert(std::numeric_limits<T>::is_integer &&
----------------
nemanjai wrote:
> I find it rather surprising that an adequate function doesn't exist in either `APInt` or somewhere in `MathExtras.h`. I wonder if adding it there might be a better place. Perhaps check with frequent contributors to those files?
`isRunOfOnes` is a wrapper around isShiftedMask defined in MathExtras.h and just returns the results of countLeadingZeros.
I found similar function in ARM, AArch64, NVPTX and AMDGPU, but they all use countTrailingZeros after isShiftedMask. It seems that what we need around isShiftedMask depends on ISA.


https://reviews.llvm.org/D33715





More information about the llvm-commits mailing list