[llvm] 6aa6ef7 - [MemCpyOpt] Don't perform call slot opt if alloc type is scalable (#75027)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 03:45:18 PST 2023
Author: Wang Pengcheng
Date: 2023-12-11T19:45:13+08:00
New Revision: 6aa6ef73ece0042953f25c4b198fdec4d6f9769d
URL: https://github.com/llvm/llvm-project/commit/6aa6ef73ece0042953f25c4b198fdec4d6f9769d
DIFF: https://github.com/llvm/llvm-project/commit/6aa6ef73ece0042953f25c4b198fdec4d6f9769d.diff
LOG: [MemCpyOpt] Don't perform call slot opt if alloc type is scalable (#75027)
This fixes #75010.
Added:
llvm/test/Transforms/MemCpyOpt/pr75010.ll
Modified:
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 0e55249d63a829..9d058e0d248378 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -880,8 +880,11 @@ bool MemCpyOptPass::performCallSlotOptzn(Instruction *cpyLoad,
return false;
const DataLayout &DL = cpyLoad->getModule()->getDataLayout();
- uint64_t srcSize = DL.getTypeAllocSize(srcAlloca->getAllocatedType()) *
- srcArraySize->getZExtValue();
+ TypeSize SrcAllocaSize = DL.getTypeAllocSize(srcAlloca->getAllocatedType());
+ // We can't optimize scalable types.
+ if (SrcAllocaSize.isScalable())
+ return false;
+ uint64_t srcSize = SrcAllocaSize * srcArraySize->getZExtValue();
if (cpySize < srcSize)
return false;
diff --git a/llvm/test/Transforms/MemCpyOpt/pr75010.ll b/llvm/test/Transforms/MemCpyOpt/pr75010.ll
new file mode 100644
index 00000000000000..c9af7543b42e64
--- /dev/null
+++ b/llvm/test/Transforms/MemCpyOpt/pr75010.ll
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -passes=memcpyopt < %s | FileCheck %s
+
+define void @f(ptr nocapture noundef writeonly %r, <vscale x 2 x i32> %x) {
+; CHECK-LABEL: @f(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[X_ADDR:%.*]] = alloca <vscale x 2 x i32>, align 8
+; CHECK-NEXT: store <vscale x 2 x i32> [[X:%.*]], ptr [[X_ADDR]], align 8
+; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr [[X_ADDR]], align 8
+; CHECK-NEXT: store i64 [[TMP0]], ptr [[R:%.*]], align 1
+; CHECK-NEXT: ret void
+;
+entry:
+ %x.addr = alloca <vscale x 2 x i32>, align 8
+ store <vscale x 2 x i32> %x, ptr %x.addr, align 8
+ %0 = load i64, ptr %x.addr, align 8
+ store i64 %0, ptr %r, align 1
+ ret void
+}
More information about the llvm-commits
mailing list