================
@@ -3488,6 +3488,24 @@ Instruction
*InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
BackIndices, GEP.getNoWrapFlags());
}
+ // Canonicalize gep %T to gep [sizeof(%T) x i8]:
+ auto IsCanonicalType = [](Type *Ty) {
+ if (auto *AT = dyn_cast<ArrayType>(Ty))
+ Ty = AT->getElementType();
+ return Ty->isIntegerTy(8);
+ };
+ if (Indices.size() == 1 && !IsCanonicalType(GEPEltType)) {
+ TypeSize Scale = DL.getTypeAllocSize(GEPEltType);
----------------
nikic wrote:
Opened https://github.com/llvm/llvm-project/pull/184364 to fix the incorrect
zero index stripping.
As a followup, fully canonicalizing GEPs in one pass instead of the combination
of 4 different transforms would allow us to directly emit the correct stride in
`[2 x i8]` form, which would allow supporting overaligned vectors again.
https://github.com/llvm/llvm-project/pull/180745
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits