[llvm] [AMDGPU][GIsel] Fix constrainRegAttrs to retain whichever of the two types is more specific instead of always adopting ConstrainingRegTy (PR #227226)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 06:00:41 PDT 2026


================
@@ -113,8 +113,17 @@ MachineRegisterInfo::constrainRegAttrs(Register Reg,
     } else if (RegCB != ConstrainingRegCB)
       return false;
   }
-  if (ConstrainingRegTy.isValid())
+  if (ConstrainingRegTy.isValid()) {
+    // RegTy and ConstrainingRegTy can be "equal" here while having different
+    // LLT::Kind, e.g. an untyped ANY_SCALAR vs a typed INTEGER/FLOAT of the
+    // same size (LLT::operator== treats these as equal). Don't lose the more
+    // specific type by blindly copying over ConstrainingRegTy in that case.
+    if (RegTy.isValid() &&
+        RegTy.isAnyScalar() != ConstrainingRegTy.isAnyScalar() &&
+        ConstrainingRegTy.isAnyScalar())
+      return true;
----------------
adeshcom14 wrote:

okay, will take a look.

https://github.com/llvm/llvm-project/pull/227226


More information about the llvm-commits mailing list