GlobalISel: Drop original type pointeriness in minScalarSameAs
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 22 Jul 2020 13:52:49 +0000 (09:52 -0400)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 24 Jul 2020 01:17:18 +0000 (21:17 -0400)
It is not useful to report WidenScalar for a pointer value, so always
report a scalar value with the target size. This allows using this to
clamp the scalar operand to the pointer size in operations like
G_PTR_ADD or G_PTRMASK.

llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h

index 5962768..c56ccdc 100644 (file)
@@ -894,9 +894,10 @@ public:
                  Query.Types[TypeIdx].getSizeInBits();
         },
         [=](const LegalityQuery &Query) {
-          LLT T = Query.Types[LargeTypeIdx];
-          return std::make_pair(TypeIdx,
-                                T.isVector() ? T.getElementType() : T);
+          const LLT Ty = Query.Types[TypeIdx];
+          const LLT LargeTy = Query.Types[LargeTypeIdx];
+          LLT NewEltTy = LLT::scalar(LargeTy.getScalarSizeInBits());
+          return std::make_pair(TypeIdx, Ty.changeElementType(NewEltTy));
         });
   }