[llvm] [GlobalISel][AArch64][AMDGPU] Expand FPOWI into series of multiplication (PR #95217)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 22 07:51:17 PDT 2024


isuckatcs wrote:

> Should this call isBeneficialToExpandPowI too? Otherwise it might expand to a lot of multiplies.

Said function is defined like this:
```c++
  /// Return true if it is beneficial to expand an @llvm.powi.* intrinsic.
  /// If not optimizing for size, expanding @llvm.powi.* intrinsics is always
  /// considered beneficial.
  /// If optimizing for size, expansion is only considered beneficial for upto
  /// 5 multiplies and a divide (if the exponent is negative).
  bool isBeneficialToExpandPowI(int64_t Exponent, bool OptForSize) const {
    if (Exponent < 0)
      Exponent = -Exponent;
    uint64_t E = static_cast<uint64_t>(Exponent);
    return !OptForSize || (llvm::popcount(E) + Log2_64(E) < 7);
  }
```
So, the intrinsic is always expanded unless if we optimize for size. I haven't seen any check
for size optimization inside selection dag, and I'm not even sure we check it there.

https://github.com/llvm/llvm-project/pull/95217


More information about the llvm-commits mailing list