Skip to content

Commit 7af3432

Browse files
committed
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
1 parent b96ca6b commit 7af3432

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/lib/CodeGen/CalcSpillWeights.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ VirtRegAuxInfo::calculateSpillWeightAndHint(LiveInterval &li) {
149149
unsigned hint = copyHint(mi, li.reg, tri, mri);
150150
if (!hint)
151151
continue;
152-
float hweight = Hint[hint] += weight;
152+
// Force hweight onto the stack so that x86 doesn't add hidden precision,
153+
// making the comparison incorrectly pass (i.e., 1 > 1 == true??).
154+
//
155+
// FIXME: we probably shouldn't use floats at all.
156+
volatile float hweight = Hint[hint] += weight;
153157
if (TargetRegisterInfo::isPhysicalRegister(hint)) {
154158
if (hweight > bestPhys && mri.isAllocatable(hint))
155159
bestPhys = hweight, hintPhys = hint;

0 commit comments

Comments
 (0)