[all-commits] [llvm/llvm-project] 740d9c: [InstCombine] Fold fdiv by splat of pow/exp/powi i...

Harrison Hao via All-commits all-commits at lists.llvm.org
Tue Sep 29 02:31:49 PDT 2026


  Branch: refs/heads/users/harrisonGPU/Instcombine/powi-splat-fdiv
  Home:   https://github.com/llvm/llvm-project
  Commit: 740d9cc31204297d3aea18f91bec134a6797d62d
      https://github.com/llvm/llvm-project/commit/740d9cc31204297d3aea18f91bec134a6797d62d
  Author: Harrison Hao <tsworld1314 at gmail.com>
  Date:   2026-09-29 (Tue, 29 Sep 2026)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
    M llvm/test/Transforms/InstCombine/fdiv.ll

  Log Message:
  -----------
  [InstCombine] Fold fdiv by splat of pow/exp/powi into fmul

Extend foldFDivPowDivisor to look through a one-use splat divisor. The
exponent is negated on the scalar and the result is splatted again:

$$\frac{Z}{\mathrm{splat}(x^{y})} \to Z \cdot \mathrm{splat}(x^{-y})$$

$$\frac{Z}{\mathrm{splat}(e^{y})} \to Z \cdot \mathrm{splat}(e^{-y})$$

$$\frac{Z}{\mathrm{splat}(2^{y})} \to Z \cdot \mathrm{splat}(2^{-y})$$

$$\frac{Z}{\mathrm{splat}(x^{n})} \to Z \cdot \mathrm{splat}(x^{-n}), \quad n \in \mathbb{Z}\ (\mathrm{powi})$$

Same FMF requirements as the scalar fold: reassoc and arcp, plus ninf
for powi. This removes the reciprocal, e.g. v_rcp on AMDGPU.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list