[llvm] [LowerMemIntrinsics] Use i8 GEPs in memcpy/memmove lowering (PR #112707)

Fabian Ritter via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 01:02:35 PDT 2024


================
@@ -49,11 +49,12 @@ void llvm::createMemCpyLoopKnownSize(
   assert((!AtomicElementSize || !LoopOpType->isVectorTy()) &&
          "Atomic memcpy lowering is not supported for vector operand type");
 
+  Type *Int8Type = Type::getInt8Ty(Ctx);
   unsigned LoopOpSize = DL.getTypeStoreSize(LoopOpType);
   assert((!AtomicElementSize || LoopOpSize % *AtomicElementSize == 0) &&
-      "Atomic memcpy lowering is not supported for selected operand size");
+         "Atomic memcpy lowering is not supported for selected operand size");
 
-  uint64_t LoopEndCount = CopyLen->getZExtValue() / LoopOpSize;
+  uint64_t LoopEndCount = (CopyLen->getZExtValue() / LoopOpSize) * LoopOpSize;
----------------
ritter-x2a wrote:

The intention is to change `LoopEndCount` to contain the number of bytes copied at the end of the main loop, without the residual. This construct should produce the largest number <= `CopyLen->getZExtValue()` that is a multiple of `LoopOpSize` (the result of the integer division is truncated towards zero, before the multiplication).
Do you think that subtracting `CopyLen->getZExtValue() % LoopOpSize` from `CopyLen->getZExtValue()` instead would fit better into the project?

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


More information about the llvm-commits mailing list