[llvm] [InstCombine] Fold scalbn libcalls to llvm.ldexp (PR #216573)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 18 03:36:25 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)
----------------
arsenm wrote:
Remove the fast flags, they're not necessary for the transform. However, you should have a test with flags that shows they are preserved
https://github.com/llvm/llvm-project/pull/216573
More information about the llvm-commits
mailing list