[llvm] [clang] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 28 05:10:17 PST 2023


================
@@ -2282,6 +2282,15 @@ Instruction *InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
   if (MadeChange)
     return &GEP;
 
+  // Canonicalize constant GEPs to i8 type.
----------------
nikic wrote:

GEP operates in terms of bytes, not bits. The size of i8 is required to be 1. GEP doesn't care how the mapping from size to size in bits looks like. So if you want to map i8 to 32 bits, then that should be fine as far as GEP/ptradd are concerned (though of course breaks all kinds of other assumptions).

https://github.com/llvm/llvm-project/pull/68882


More information about the cfe-commits mailing list