[all-commits] [llvm/llvm-project] b1a304: [InstCombine] Fold select of pow into select of th...

Harrison Hao via All-commits all-commits at lists.llvm.org
Wed Sep 30 07:40:51 PDT 2026


  Branch: refs/heads/users/harrisonGPU/select-pow
  Home:   https://github.com/llvm/llvm-project
  Commit: b1a304804a91f613c02e0a6251ef8da14580752f
      https://github.com/llvm/llvm-project/commit/b1a304804a91f613c02e0a6251ef8da14580752f
  Author: Harrison Hao <tsworld1314 at gmail.com>
  Date:   2026-09-30 (Wed, 30 Sep 2026)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
    M llvm/test/Transforms/InstCombine/intrinsic-select.ll

  Log Message:
  -----------
  [InstCombine] Fold select of pow into select of the differing operand

When both arms of a select are calls to `llvm.pow` with one use that
differ in exactly one operand, sink the select into that operand:

$$
\mathrm{select}(c,\ x^{y},\ x^{z}) \rightarrow x^{\mathrm{select}(c,\ y,\ z)}
$$

$$
\mathrm{select}(c,\ x^{z},\ y^{z}) \rightarrow \mathrm{select}(c,\ x,\ y)^{z}
$$

This removes one `pow` call. FMF are intersected and debug locations
are merged. The transform is skipped when a differing operand is a
constant, since that may enable a cheaper lowering (e.g.
$x^2 \rightarrow x \cdot x$).



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