diff --git a/include/llvm/Target/TargetRegisterInfo.h b/include/llvm/Target/TargetRegisterInfo.h index 121b8a23252..1fd99a31993 100644 --- a/include/llvm/Target/TargetRegisterInfo.h +++ b/include/llvm/Target/TargetRegisterInfo.h @@ -373,6 +373,19 @@ public: return SubRegIndexLaneMasks[SubIdx]; } + /// Returns true if the given lane mask is imprecise. + /// + /// LaneMasks as given by getSubRegIndexLaneMask() have a limited number of + /// bits, so for targets with more than 31 disjunct subregister indices there + /// may be cases where: + /// getSubReg(Reg,A) does not overlap getSubReg(Reg,B) + /// but we still have + /// (getSubRegIndexLaneMask(A) & getSubRegIndexLaneMask(B)) != 0. + /// This function returns true in those cases. + static bool isImpreciseLaneMask(unsigned LaneMask) { + return LaneMask & 0x80000000u; + } + /// The lane masks returned by getSubRegIndexLaneMask() above can only be /// used to determine if sub-registers overlap - they can't be used to /// determine if a set of sub-registers completely cover another diff --git a/lib/CodeGen/RegisterCoalescer.cpp b/lib/CodeGen/RegisterCoalescer.cpp index e513a4f1ccf..7b7c7502172 100644 --- a/lib/CodeGen/RegisterCoalescer.cpp +++ b/lib/CodeGen/RegisterCoalescer.cpp @@ -2633,7 +2633,8 @@ bool RegisterCoalescer::joinVirtRegs(CoalescerPair &CP) { // "overflow bit" 32. As a workaround we drop all subregister ranges // which means we loose some precision but are back to a well defined // state. - assert((CP.getNewRC()->getLaneMask() & 0x80000000u) + assert(TargetRegisterInfo::isImpreciseLaneMask( + CP.getNewRC()->getLaneMask()) && "SubRange merge should only fail when merging into bit 32."); DEBUG(dbgs() << "\tSubrange join aborted!\n"); LHS.clearSubRanges();