Don't enable llvm's UnsafeFPMath option when --opt=fast-math is supplied.

This was causing functions like round() to fail on SSE2, since it has code
that does:

    x += 0x1.0p23f;
    x -= 0x1.0p23f;

which was in turn being undesirably optimized away.

Fixes issue #211.
This commit is contained in:
Matt Pharr
2012-03-28 10:26:39 -07:00
parent d0d9aae968
commit b3c5043dcc

View File

@@ -355,8 +355,15 @@ Target::GetTargetMachine() const {
#if defined(LLVM_3_1svn)
std::string featuresString = attributes;
llvm::TargetOptions options;
#if 0
// This was breaking e.g. round() on SSE2, where the code we want to
// run wants to do:
// x += 0x1.0p23f;
// x -= 0x1.0p23f;
// But then LLVM was optimizing this away...
if (g->opt.fastMath == true)
options.UnsafeFPMath = 1;
#endif
llvm::TargetMachine *targetMachine =
target->createTargetMachine(triple, cpu, featuresString, options,
relocModel);