[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)

Momchil Velikov via cfe-commits cfe-commits at lists.llvm.org
Wed May 29 06:21:59 PDT 2024


================
@@ -1989,6 +1989,14 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile,
     return EmitAtomicLoad(AtomicLValue, Loc).getScalarVal();
   }
 
+  if (const auto *BIT = Ty->getAs<BitIntType>()) {
+    if (BIT->getNumBits() > 128) {
+      // Long _BitInt has array of bytes as in-memory type.
+      llvm::Type *NewTy = ConvertType(Ty);
----------------
momchil-velikov wrote:

Oh, I see. It looks close to what we are trying to do with https://github.com/llvm/llvm-project/pull/93495, which is:
* create in-memory representations according to the target ABI
* improve efficiency of loads/stores, e.g. load/store of `i18` in LLVM must touch just 3 bytes, so a compiler would emit one 16-bit load and one 8-bit load, but if `i18` comes from `_BitInt(18)` then a single 32-bit load would work better.

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


More information about the cfe-commits mailing list