[llvm] [ConstantFold] Fold `logb` and `logbf` when the input parameter is a constant value. (PR #111232)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 00:08:54 PDT 2024
================
@@ -0,0 +1,59 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+
+define float @logbf_const() {
+; CHECK-LABEL: define float @logbf_const() {
+; CHECK-NEXT: [[R:%.*]] = call float @logbf(float 7.000000e+00)
+; CHECK-NEXT: ret float 2.000000e+00
+;
+ %r = call float @logbf(float 7.000000e+00)
+ ret float %r
+}
+
+define double @logb_const() {
+; CHECK-LABEL: define double @logb_const() {
+; CHECK-NEXT: [[R:%.*]] = call double @logb(double -7.000000e+00)
+; CHECK-NEXT: ret double 2.000000e+00
+;
+ %r = call double @logb(double -7.000000e+00)
+ ret double %r
+}
+
+define float @logbf_zero() {
+; CHECK-LABEL: define float @logbf_zero() {
+; CHECK-NEXT: [[R:%.*]] = call float @logbf(float 0.000000e+00)
+; CHECK-NEXT: ret float [[R]]
+;
+ %r = call float @logbf(float 0.000000e+00)
+ ret float %r
+}
+
+define double @logb_zero() {
----------------
arsenm wrote:
Fold the zero case when readnone?
https://github.com/llvm/llvm-project/pull/111232
More information about the llvm-commits
mailing list