Skip to content

Commit 8a88533

Browse files
committed
fixup! [LowerMemIntrinsics] Use i8 GEPs in memcpy/memmove lowering
use alignDown instead of dividing and multiplying by LoopOpSize
1 parent 76a5d56 commit 8a88533

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void llvm::createMemCpyLoopKnownSize(
5454
assert((!AtomicElementSize || LoopOpSize % *AtomicElementSize == 0) &&
5555
"Atomic memcpy lowering is not supported for selected operand size");
5656

57-
uint64_t LoopEndCount = (CopyLen->getZExtValue() / LoopOpSize) * LoopOpSize;
57+
uint64_t LoopEndCount = alignDown(CopyLen->getZExtValue(), LoopOpSize);
5858

5959
if (LoopEndCount != 0) {
6060
// Split
@@ -676,8 +676,7 @@ static void createMemMoveLoopKnownSize(Instruction *InsertBefore,
676676
Type *Int8Type = Type::getInt8Ty(Ctx);
677677

678678
// Calculate the loop trip count and remaining bytes to copy after the loop.
679-
uint64_t BytesCopiedInLoop =
680-
(CopyLen->getZExtValue() / LoopOpSize) * LoopOpSize;
679+
uint64_t BytesCopiedInLoop = alignDown(CopyLen->getZExtValue(), LoopOpSize);
681680
uint64_t RemainingBytes = CopyLen->getZExtValue() - BytesCopiedInLoop;
682681

683682
IntegerType *ILengthType = cast<IntegerType>(TypeOfCopyLen);

0 commit comments

Comments
 (0)