Skip to content

Commit 8e62ffd

Browse files
committed
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.
1 parent dfae717 commit 8e62ffd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -894,9 +894,10 @@ class LegalizeRuleSet {
894894
Query.Types[TypeIdx].getSizeInBits();
895895
},
896896
[=](const LegalityQuery &Query) {
897-
LLT T = Query.Types[LargeTypeIdx];
898-
return std::make_pair(TypeIdx,
899-
T.isVector() ? T.getElementType() : T);
897+
const LLT Ty = Query.Types[TypeIdx];
898+
const LLT LargeTy = Query.Types[LargeTypeIdx];
899+
LLT NewEltTy = LLT::scalar(LargeTy.getScalarSizeInBits());
900+
return std::make_pair(TypeIdx, Ty.changeElementType(NewEltTy));
900901
});
901902
}
902903

0 commit comments

Comments
 (0)