//===- VecUtils.cpp -------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h" namespace llvm::sandboxir { unsigned VecUtils::getFloorPowerOf2(unsigned Num) { if (Num == 0) return Num; unsigned Mask = Num; Mask >>= 1; for (unsigned ShiftBy = 1; ShiftBy < sizeof(Num) * 8; ShiftBy <<= 1) Mask |= Mask >> ShiftBy; return Num & ~Mask; } #ifndef NDEBUG template static void dumpImpl(ArrayRef Bndl) { for (auto [Idx, V] : enumerate(Bndl)) dbgs() << Idx << "." << *V << "\n"; } void VecUtils::dump(ArrayRef Bndl) { dumpImpl(Bndl); } void VecUtils::dump(ArrayRef Bndl) { dumpImpl(Bndl); } #endif // NDEBUG } // namespace llvm::sandboxir