diff --git a/utils/TableGen/CodeEmitterGen.cpp b/utils/TableGen/CodeEmitterGen.cpp index 957dd19da1c..9d4dc5c4607 100644 --- a/utils/TableGen/CodeEmitterGen.cpp +++ b/utils/TableGen/CodeEmitterGen.cpp @@ -63,10 +63,14 @@ void CodeEmitterGen::reverseBits(std::vector &Insts) { // return the variable bit position. Otherwise return -1. int CodeEmitterGen::getVariableBit(const std::string &VarName, BitsInit *BI, int bit) { - if (VarBitInit *VBI = dynamic_cast(BI->getBit(bit))) + if (VarBitInit *VBI = dynamic_cast(BI->getBit(bit))) { if (VarInit *VI = dynamic_cast(VBI->getVariable())) if (VI->getName() == VarName) return VBI->getBitNum(); + } else if (VarInit *VI = dynamic_cast(BI->getBit(bit))) { + if (VI->getName() == VarName) + return 0; + } return -1; }