[llvm] [SimplifyLibCalls] Constant fold scalbxx (PR #114417)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 22 11:07:25 PST 2024
================
@@ -0,0 +1,89 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
+
+declare double @scalbln(double, i64)
+declare float @scalblnf(float, i64)
+declare x86_fp80 @scalblnl(x86_fp80, i64)
+declare double @scalbn(double, i32)
+declare float @scalbnf(float, i32)
+declare x86_fp80 @scalbnl(x86_fp80, i32)
+
+define double @scalbln_undef() {
+; CHECK-LABEL: @scalbln_undef(
+; CHECK-NEXT: ret double 0x7FF8000000000000
+;
+ %call = call double @scalbln(double undef, i64 undef)
+ ret double %call
+}
+
+define float @scalblnf_undef() {
+; CHECK-LABEL: @scalblnf_undef(
+; CHECK-NEXT: ret float 0x7FF8000000000000
+;
+ %call = call float @scalblnf(float undef, i64 undef)
+ ret float %call
+}
+
+define x86_fp80 @scalblnl_undef() {
+; CHECK-LABEL: @scalblnl_undef(
+; CHECK-NEXT: ret x86_fp80 0x7FF8000000000000
+;
+ %call = call x86_fp80 @scalblnl(x86_fp80 undef, i64 undef)
+ ret x86_fp80 %call
+}
+
+define double @scalbn_undef() {
+; CHECK-LABEL: @scalbn_undef(
+; CHECK-NEXT: ret double 0x7FF8000000000000
+;
+ %call = call double @scalbn(double undef, i32 undef)
+ ret double %call
+}
+
+define float @scalbnf_undef() {
+; CHECK-LABEL: @scalbnf_undef(
+; CHECK-NEXT: ret float 0x7FF8000000000000
+;
+ %call = call float @scalbnf(float undef, i32 undef)
+ ret float %call
+}
+
+define x86_fp80 @scalbnl_undef() {
+; CHECK-LABEL: @scalbnl_undef(
+; CHECK-NEXT: ret x86_fp80 0x7FF8000000000000
+;
+ %call = call x86_fp80 @scalbnl(x86_fp80 undef, i32 undef)
+ ret x86_fp80 %call
+}
+
+define double @scalbn_check() {
+; CHECK-LABEL: @scalbn_check(
+; CHECK-NEXT: ret double 12.0
+;
+ %call = call double @scalbn(double 3.0, i32 2)
+ ret %call
+}
+
+define double @scalbn_check0() {
+; CHECK-LABEL: @scalbn_check0(
+; CHECK-NEXT: ret double 0.0
+;
+ %call = call double @scalbn(double 0.0, i32 2)
+ ret %call
+}
+
+define double @scalbn_check0n() {
+; CHECK-LABEL: @scalbn_check0n(
+; CHECK-NEXT: ret double 0.0
+;
+ %call = call double @scalbn(double -0.0, i32 2)
+ ret %call
+}
+
+define double @scalbn_check0n2() {
+; CHECK-LABEL: @scalbn_check0n2(
+; CHECK-NEXT: ret double 0.5
+;
+ %call = call double @scalbn(double 1.0, i32 -1)
+ ret %call
+}
----------------
arsenm wrote:
Negative test on overflow when errno is set
https://github.com/llvm/llvm-project/pull/114417
More information about the llvm-commits
mailing list