CalcSpillWeights: Hack to prevent x87 nonsense

This gross hack forces `hweight` into memory, preventing hidden
precision from making `1 > 1` occasionally equal `true`.

<rdar://problem/14292693>

llvm-svn: 206765
This commit is contained in:
Duncan P. N. Exon Smith 2014-04-21 17:57:01 +00:00
parent b96ca6b0c8
commit 7af3432e22
1 changed files with 5 additions and 1 deletions

View File

@ -149,7 +149,11 @@ VirtRegAuxInfo::calculateSpillWeightAndHint(LiveInterval &li) {
unsigned hint = copyHint(mi, li.reg, tri, mri);
if (!hint)
continue;
float hweight = Hint[hint] += weight;
// Force hweight onto the stack so that x86 doesn't add hidden precision,
// making the comparison incorrectly pass (i.e., 1 > 1 == true??).
//
// FIXME: we probably shouldn't use floats at all.
volatile float hweight = Hint[hint] += weight;
if (TargetRegisterInfo::isPhysicalRegister(hint)) {
if (hweight > bestPhys && mri.isAllocatable(hint))
bestPhys = hweight, hintPhys = hint;