[llvm] [InstCombine] Fold scalbn libcalls to llvm.ldexp (PR #216573)

Hadong Lee via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 06:21:09 PDT 2026


================
@@ -0,0 +1,78 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt -S -passes=instcombine < %s | FileCheck %s
+
+declare float @scalbnf(float, i32)
+declare double @scalbn(double, i32)
+declare fp128 @scalbnl(fp128, i32)
+
+; Cover the float variant and preservation of fast-math flags and tail calls.
+
+define float @scalbnf_f32(float %x, i32 %exp) {
+; CHECK-LABEL: define float @scalbnf_f32(
+; CHECK-SAME: float [[X:%.*]], i32 [[EXP:%.*]]) {
+; CHECK-NEXT:    [[R:%.*]] = tail call fast float @llvm.ldexp.f32.i32(float [[X]], i32 [[EXP]])
+; CHECK-NEXT:    ret float [[R]]
+;
+  %r = tail call fast float @scalbnf(float %x, i32 %exp) memory(none)
----------------
ChrisLee02 wrote:

https://github.com/llvm/llvm-project/commit/844a710e8806c438afee90315a685d16ee351d3c

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


More information about the llvm-commits mailing list