================ @@ -2282,6 +2282,15 @@ Instruction *InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) { if (MadeChange) return &GEP; + // Canonicalize constant GEPs to i8 type. ---------------- bjope wrote:
FWIW, this is a bit interesting downstream with non-8-bit addressing units :-) Today i8 would be quite rare as GEP type for us as it is smaller than the addressing unit size. But I figure that canonicalizing to some other type downstream could end up as a lot of work (or lots of missed optimizations). Afaict accumulateConstantOffset is returning an offset that depends on TypeStoreSize. So as long as this is used in a way so that the address still would be given by `baseptr + DL.getTypeStoreSize(i8) * Offset` and not `baseptr + 8 * Offset` , then I guess things will be fine (i.e not assuming that the offset is an 8-bit offset). As far as I can tell you could just as well have picked i1 instead of i8 (given that `DL.getTypeStoreSize(i1)==DL.getTypeStoreSize(i8)`). That would probably look confusing, but that is what happens for us when using i8 as type as we can't address individual octets. (I also see this as a reminder for looking at the ptradd RFC to understand how that will impact us, so that we are prepared for that.) https://github.com/llvm/llvm-project/pull/68882 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits