[PATCH] D118766: [CodeGen] Use the non-pointer LLT equivalent to check regclass type

Lewis Revill via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 2 02:39:06 PST 2022


lewis-revill created this revision.
lewis-revill added reviewers: dsanders, arsenm.
Herald added a subscriber: simoncook.
lewis-revill requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

When we check the type legality of assigning a given LLT to a register class, we compare the LLT equivalents of the MVTs assigned to the register class to the given LLT. However since no MVTs match to the pointer LLTs, we always return false when given a pointer LLT - even if the type size and shape is legal for the register class.

This patch simply uses the non-pointer LLT equivalent to compare against the LLT equivalents of the MVTs assigned to the register class instead. Thus we can report pointer types as legal for register classes when their size and shape is legal.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118766

Files:
  llvm/include/llvm/CodeGen/TargetRegisterInfo.h


Index: llvm/include/llvm/CodeGen/TargetRegisterInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/TargetRegisterInfo.h
+++ 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118766.405187.patch
Type: text/x-patch
Size: 932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220202/38d5079d/attachment.bin>


More information about the llvm-commits mailing list