[PATCH] D84325: GlobalISel: Drop original type pointeriness in minScalarSameAs

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 07:18:01 PDT 2020


arsenm created this revision.
arsenm added reviewers: aemerson, paquette, aditya_nandakumar, dsanders.
Herald added subscribers: arichardson, rovka, wdng.
Herald added a project: LLVM.

It is not useful to report WidenScalar for a pointer value, so always
report a scalar value in 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.


https://reviews.llvm.org/D84325

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


Index: llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
+++ llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
@@ -912,9 +912,10 @@
                  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));
         });
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84325.279816.patch
Type: text/x-patch
Size: 806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200722/3cd79ee4/attachment.bin>


More information about the llvm-commits mailing list