[all-commits] [llvm/llvm-project] 14baa8: [InstCombine] Fix invalid IR when folding frexp(fr...

Justin Lebar via All-commits all-commits at lists.llvm.org
Mon Jun 8 13:46:45 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 14baa81e24fcd22cca188cabe3a6c76debd14c95
      https://github.com/llvm/llvm-project/commit/14baa81e24fcd22cca188cabe3a6c76debd14c95
  Author: Justin Lebar <justin.lebar at gmail.com>
  Date:   2026-06-08 (Mon, 08 Jun 2026)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    M llvm/test/Transforms/InstCombine/frexp.ll

  Log Message:
  -----------
  [InstCombine] Fix invalid IR when folding frexp(frexp(x)) with mismatched exponent types (#202419)

Instcombine folds the idempotent frexp pattern

    %inner = call { double, i64 } @llvm.frexp.f64.i64(double %x)
    %f     = extractvalue { double, i64 } %inner, 0
    %outer = call { double, i32 } @llvm.frexp.f64.i32(double %f)

to `{ %f, 0 }`, because the fraction after the first frexp call is known
0.  It did this by reusing the inner frexp's result struct and
overwriting field 1 with zero.

But you can see in this example that reusing the inner frexp's
result struct is invalid, because that call returns { double, i64 },
whereas the second call returns { double, i32 }.

Fix this by building the new struct instead of modifying the old one.



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