[AArch64][GlobalISel] Improve legalization of G_PTR_ADD (#91763)
The testing we have for vector ptradd was a bit lacking. In adding tests
this patch found a couple of issues mostly with the way v3 vectors of
ptrs were sometimes legalized via i64, and with non-i64 additions. It
does not attempt to fix the issue with mergevalues from returning vector
ptrs.
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index 6a76ad7..4050784 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -69,8 +69,9 @@
unsigned EltSize = OrigTy.getScalarSizeInBits();
if (LeftoverSize % EltSize != 0)
return {-1, -1};
- LeftoverTy = LLT::scalarOrVector(
- ElementCount::getFixed(LeftoverSize / EltSize), EltSize);
+ LeftoverTy =
+ LLT::scalarOrVector(ElementCount::getFixed(LeftoverSize / EltSize),
+ OrigTy.getElementType());
} else {
LeftoverTy = LLT::scalar(LeftoverSize);
}
@@ -212,7 +213,7 @@
appendVectorElts(AllElts, PartRegs[i]);
Register Leftover = PartRegs[PartRegs.size() - 1];
- if (MRI.getType(Leftover).isScalar())
+ if (!MRI.getType(Leftover).isVector())
AllElts.push_back(Leftover);
else
appendVectorElts(AllElts, Leftover);