mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-16 16:48:02 +00:00
Don't use floating point to do an integer's job.
This code makes different decisions when compiled into x87 instructions because of different rounding behavior. That caused phase 2/3 miscompares on 32-bit Linux when the phase 1 compiler was built with gcc (using x87), and the phase 2 compiler was built with clang (using SSE). This fixes PR11200. llvm-svn: 143006
This commit is contained in:
parent
c3031bd208
commit
4512ad38b1
@ -2034,14 +2034,17 @@ bool SelectionDAGBuilder::handleJTSwitchCase(CaseRec &CR,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
APInt Range = ComputeRange(First, Last);
|
APInt Range = ComputeRange(First, Last);
|
||||||
double Density = TSize.roundToDouble() / Range.roundToDouble();
|
// The density is TSize / Range. Require at least 40%.
|
||||||
if (Density < 0.4)
|
// It should not be possible for IntTSize to saturate for sane code, but make
|
||||||
|
// sure we handle Range saturation correctly.
|
||||||
|
uint64_t IntRange = Range.getLimitedValue(UINT64_MAX/10);
|
||||||
|
uint64_t IntTSize = TSize.getLimitedValue(UINT64_MAX/10);
|
||||||
|
if (IntTSize * 10 < IntRange * 4)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DEBUG(dbgs() << "Lowering jump table\n"
|
DEBUG(dbgs() << "Lowering jump table\n"
|
||||||
<< "First entry: " << First << ". Last entry: " << Last << '\n'
|
<< "First entry: " << First << ". Last entry: " << Last << '\n'
|
||||||
<< "Range: " << Range
|
<< "Range: " << Range << ". Size: " << TSize << ".\n\n");
|
||||||
<< ". Size: " << TSize << ". Density: " << Density << "\n\n");
|
|
||||||
|
|
||||||
// Get the MachineFunction which holds the current MBB. This is used when
|
// Get the MachineFunction which holds the current MBB. This is used when
|
||||||
// inserting any additional MBBs necessary to represent the switch.
|
// inserting any additional MBBs necessary to represent the switch.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user