Subzero: Make sure register preferences obey register class constraints.
The bug was first spotted in the optimized gl_Color4ub() from spec2k's mesa. The lowering sequences for fptosi and fptoui with i8 or i16 include "mov T_2, T_1" where T_1 and T_2 may have different integer types, and the statement:
T_2->setPreferredRegister(T_1, true);
If T_2's type is i8 and T_1 is assigned a register that has no 8-bit version, then T_2 gets an unsuitable register.
The fix is to honor RegisterOverlap only when RegMask allows.
It's hard to construct a good test for this, since it depends heavily on register allocation decisions, which will change over time.
BUG= none
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/544713002
diff --git a/src/IceRegAlloc.cpp b/src/IceRegAlloc.cpp
index 10a02a3..ce08c6a 100644
--- a/src/IceRegAlloc.cpp
+++ b/src/IceRegAlloc.cpp
@@ -233,6 +233,7 @@
: Variable::NoRegister;
bool AllowedToOverlap = Cur.Var->getRegisterOverlap() &&
PreferReg != Variable::NoRegister &&
+ RegMask[PreferReg] &&
!PrecoloredUnhandled[PreferReg];
if (PreferReg != Variable::NoRegister &&
(AllowedToOverlap || Free[PreferReg])) {