Well, I found out the reason why this assert is here, and this is problematic.
CondCodeActions only supports up to 32 different value types. Since we are past 32, what LLVM has is broken.
Currently the 4 different Legalize states are stored in successive bits and packed into a uin64_t, see TargetLowering.h.
/// CondCodeActions - For each condition code (ISD::CondCode) keep a
/// LegalizeAction that indicates how instruction selection should
/// deal with the condition code.
uint64_t CondCodeActions[ISD::SETCC_INVALID];
What I suggest is the following:
Change the definition of CondCodeAction to:
uint64_t CondCodeActions[ISD::SETCC_INVALID][2];
setCondCodeAction then becomes:
void setCondCodeAction(ISD::CondCode CC, MVT VT,
LegalizeAction Action) {
assert(VT < MVT::LAST_VALUETYPE &&
(unsigned)CC < array_lengthof(CondCodeActions) &&
“Table isn’t big enough!”);
CondCodeActions[(unsigned)CC][VT.SimplyTy >> 5] &= ~(uint64_t(3UL) << (VT.SimpleTy - 32)*2);
CondCodeActions[(unsigned)CC][VT.SimpleTy >> 5] |= (uint64_t)Action << (VT.SimpleTy - 32)*2;
}
getCondCodeAction then becomes:
LegalizeAction
getCondCodeAction(ISD::CondCode CC, EVT VT) const {
assert((unsigned)CC < array_lengthof(CondCodeActions) &&
(unsigned)VT.getSimpleVT().SimpleTy < MVT::LAST_VECTOR_VALUETYPE &&
“Table isn’t big enough!”);
LegalizeAction Action = (LegalizeAction)
((CondCodeActions[CC][VT.getSimpleVT().SimpleTy >> 5] >> (2*(VT.getSimpleVT().SimpleTy - 32))) & 3);
assert(Action != Promote && “Can’t promote condition code!”);
return Action;
}
The other options are to use a BitVector, or to have a different array for each Legalized action. This approach however seems to use the minimum amount of memory/instructions.
Ideas?
Micah