Skip to content
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

miscompile from r248638 #25326

Closed
llvmbot opened this issue Sep 27, 2015 · 5 comments
Closed

miscompile from r248638 #25326

llvmbot opened this issue Sep 27, 2015 · 5 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 27, 2015

Bugzilla Link 24952
Resolution FIXED
Resolved on Sep 27, 2015 16:21
Version unspecified
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @hfinkel,@sanjoy

Extended Description

The boost example,

#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/math/special_functions/gamma.hpp>
#include
int main() {
using namespace boost::multiprecision;
std::cout << boost::math::tgamma(cpp_bin_float_100(1000)) << std::endl;
}

produce correct output

bin/clang++ -O2 -std=c++11 -isystem include cpp_bin_float_snips.cpp
./a.out
4.02387e+2564

with pre-r248638 clang and gcc 5.1.0.

From r248638,

./a.out
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorstd::range_error >'
what(): No bits were set in the operand.

this is on Ubunto 14.04 64 bit, boost 1.57.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Sep 27, 2015

assigned to @sanjoy

@sanjoy
Copy link
Contributor

sanjoy commented Sep 27, 2015

I think this is a glitch with how isIdenticalTo is used in
ScalarEvolution.

Can you check if clang built with this patch below fixes the issue?

diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 32d3d36..bfd6c45 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -6418,7 +6418,8 @@ static bool HasSameValue(const SCEV *A, const SCEV *B) {
if (const SCEVUnknown *BU = dyn_cast(B))
if (const Instruction *AI = dyn_cast(AU->getValue()))
if (const Instruction *BI = dyn_cast(BU->getValue()))

  •      if (AI->isIdenticalTo(BI) && !AI->mayReadFromMemory())
    
  •      if (AI->isIdenticalTo(BI) && !AI->mayReadFromMemory() &&
    
  •          !isa<AllocaInst>(AI))
           return true;
    

    // Otherwise assume they may have a different value.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Sep 27, 2015

Yes, this patch does solve the problem.
Thanks for looking into this!

@sanjoy
Copy link
Contributor

sanjoy commented Sep 27, 2015

Should be fixed in r248690

@llvmbot
Copy link
Collaborator Author

llvmbot commented Sep 27, 2015

Confirmed, r248690 fixes the problem.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

2 participants