================
@@ -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);
----------------
dtcxzyw wrote:
I am not sure if we should respect ABI alignment in GEP:
https://godbolt.org/z/bM1zdT96h
The current canonicalization doubles the stride.
If the answer is yes, it may be problematic to strip the leading zero index of
a GEP with a vector source element type.
See also https://github.com/llvm/llvm-project/pull/75448.
https://github.com/llvm/llvm-project/pull/180745
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits