[all-commits] [llvm/llvm-project] 55be37: [InstCombine] Fold frexp of select to select of fr...

Narayan via All-commits all-commits at lists.llvm.org
Fri Jan 31 07:18:20 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 55be370f375416f615a840d1c0cabe2c819e6bbb
      https://github.com/llvm/llvm-project/commit/55be370f375416f615a840d1c0cabe2c819e6bbb
  Author: Narayan <32898329+vortex73 at users.noreply.github.com>
  Date:   2025-01-31 (Fri, 31 Jan 2025)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    A llvm/test/Transforms/InstCombine/select_frexp.ll

  Log Message:
  -----------
  [InstCombine] Fold frexp of select to select of frexp (#121227)

This patch implements an optimization to push select operations through
frexp when one of the select operands is a constant. When we encounter:
```
define float @src(float %x, i1 %bool) {
  %select = select i1 %bool, float 1.000000e+00, float %x
  %frexp = tail call { float, i32 } @llvm.frexp.f32.i32(float %select)
  %frexp.0 = extractvalue { float, i32 } %frexp, 0
  ret float %frexp.0
}
```
We transform it to:
```
define float @tgt(float %x, i1 %bool) {
  %frexp = tail call { float, i32 } @llvm.frexp.f32.i32(float %x)
  %frexp.0 = extractvalue { float, i32 } %frexp, 0
  %select = select i1 %bool, float 5.000000e-01, float %frexp.0
  ret float %select
}
```

Fixes #92542



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