diff --git a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h --- a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h +++ b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h @@ -299,12 +299,16 @@ /// Return true if the given TargetRegisterClass is compatible with LLT T. bool isTypeLegalForClass(const TargetRegisterClass &RC, LLT T) const { + // There's no equivalent MVT for LLT pointer types, so here we transform the + // LLT to its non-pointer equivalent before checking legality based on just + // the size and shape if applicable. + LLT NonPtrT = T.changeElementType(LLT::scalar(T.getScalarSizeInBits())); for (auto I = legalclasstypes_begin(RC); *I != MVT::Other; ++I) { MVT VT(*I); if (VT == MVT::Untyped) return true; - if (LLT(VT) == T) + if (LLT(VT) == NonPtrT) return true; } return false;