From: Duncan P. N. Exon Smith Date: Mon, 21 Apr 2014 17:57:01 +0000 (+0000) Subject: CalcSpillWeights: Hack to prevent x87 nonsense X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d5ebbc5edf14085729951759e02def382a39cab3;p=oota-llvm.git CalcSpillWeights: Hack to prevent x87 nonsense This gross hack forces `hweight` into memory, preventing hidden precision from making `1 > 1` occasionally equal `true`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206765 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CalcSpillWeights.cpp b/lib/CodeGen/CalcSpillWeights.cpp index e4d5fa80ca3..2654f42d2c6 100644 --- a/lib/CodeGen/CalcSpillWeights.cpp +++ b/lib/CodeGen/CalcSpillWeights.cpp @@ -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;