[llvm] 8e62ffd - GlobalISel: Drop original type pointeriness in minScalarSameAs

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 23 18:46:43 PDT 2020


Author: Matt Arsenault
Date: 2020-07-23T21:17:18-04:00
New Revision: 8e62ffdef1c8e50cc0f108b1d67a37bcb6089279

URL: https://github.com/llvm/llvm-project/commit/8e62ffdef1c8e50cc0f108b1d67a37bcb6089279
DIFF: https://github.com/llvm/llvm-project/commit/8e62ffdef1c8e50cc0f108b1d67a37bcb6089279.diff

LOG: GlobalISel: Drop original type pointeriness in minScalarSameAs

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.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
index 5962768c206c..c56ccdcb747a 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
@@ -894,9 +894,10 @@ class LegalizeRuleSet {
                  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));
         });
   }
 


        


More information about the llvm-commits mailing list