-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ConstantFold] Special case log1p +/-0.0 #114635
[ConstantFold] Special case log1p +/-0.0 #114635
Conversation
This reverts commit 900b636.
C's Annex F specifies that log1p +/-0.0 returns the input value; however, this behavior is optional and host C libraries may behave differently. This change applies the Annex F behavior to constant folding by LLVM.
@llvm/pr-subscribers-llvm-transforms Author: Hubert Tong (hubert-reinterpretcast) ChangesC's Annex F specifies that log1p +/-0.0 returns the input value; Full diff: https://github.com/llvm/llvm-project/pull/114635.diff 2 Files Affected:
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index c5a2c2f52f8dc2..88db315ffd0bcb 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -2407,6 +2407,9 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
break;
case LibFunc_log1p:
case LibFunc_log1pf:
+ // Implement optional behavior from C's Annex F for +/-0.0.
+ if (U.isZero())
+ return ConstantFP::get(Ty->getContext(), U);
if (APF > APFloat::getOne(APF.getSemantics(), true) && TLI->has(Func))
return ConstantFoldFP(log1p, APF, Ty);
break;
diff --git a/llvm/test/Transforms/InstCombine/log1p.ll b/llvm/test/Transforms/InstCombine/log1p.ll
index bbf89db8c34105..81d3cc8a4f7ac9 100644
--- a/llvm/test/Transforms/InstCombine/log1p.ll
+++ b/llvm/test/Transforms/InstCombine/log1p.ll
@@ -1,4 +1,3 @@
-; XFAIL: target={{.*}}-aix{{.*}}
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
|
@llvm/pr-subscribers-llvm-analysis Author: Hubert Tong (hubert-reinterpretcast) ChangesC's Annex F specifies that log1p +/-0.0 returns the input value; Full diff: https://github.com/llvm/llvm-project/pull/114635.diff 2 Files Affected:
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index c5a2c2f52f8dc2..88db315ffd0bcb 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -2407,6 +2407,9 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
break;
case LibFunc_log1p:
case LibFunc_log1pf:
+ // Implement optional behavior from C's Annex F for +/-0.0.
+ if (U.isZero())
+ return ConstantFP::get(Ty->getContext(), U);
if (APF > APFloat::getOne(APF.getSemantics(), true) && TLI->has(Func))
return ConstantFoldFP(log1p, APF, Ty);
break;
diff --git a/llvm/test/Transforms/InstCombine/log1p.ll b/llvm/test/Transforms/InstCombine/log1p.ll
index bbf89db8c34105..81d3cc8a4f7ac9 100644
--- a/llvm/test/Transforms/InstCombine/log1p.ll
+++ b/llvm/test/Transforms/InstCombine/log1p.ll
@@ -1,4 +1,3 @@
-; XFAIL: target={{.*}}-aix{{.*}}
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/42/builds/1739 Here is the relevant piece of the build log for the reference
|
C's Annex F specifies that log1p +/-0.0 returns the input value; however, this behavior is optional and host C libraries may behave differently. This change applies the Annex F behavior to constant folding by LLVM.
C's Annex F specifies that log1p +/-0.0 returns the input value; however, this behavior is optional and host C libraries may behave differently. This change applies the Annex F behavior to constant folding by LLVM.
C's Annex F specifies that log1p +/-0.0 returns the input value; however, this behavior is optional and host C libraries may behave differently. This change applies the Annex F behavior to constant folding by LLVM.
C's Annex F specifies that log1p +/-0.0 returns the input value;
however, this behavior is optional and host C libraries may behave
differently. This change applies the Annex F behavior to constant
folding by LLVM.