Skip to content

Commit 6aa6ef7

Browse files
authored
[MemCpyOpt] Don't perform call slot opt if alloc type is scalable (#75027)
This fixes #75010.
1 parent ed07fc8 commit 6aa6ef7

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,11 @@ bool MemCpyOptPass::performCallSlotOptzn(Instruction *cpyLoad,
880880
return false;
881881

882882
const DataLayout &DL = cpyLoad->getModule()->getDataLayout();
883-
uint64_t srcSize = DL.getTypeAllocSize(srcAlloca->getAllocatedType()) *
884-
srcArraySize->getZExtValue();
883+
TypeSize SrcAllocaSize = DL.getTypeAllocSize(srcAlloca->getAllocatedType());
884+
// We can't optimize scalable types.
885+
if (SrcAllocaSize.isScalable())
886+
return false;
887+
uint64_t srcSize = SrcAllocaSize * srcArraySize->getZExtValue();
885888

886889
if (cpySize < srcSize)
887890
return false;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -S -passes=memcpyopt < %s | FileCheck %s
3+
4+
define void @f(ptr nocapture noundef writeonly %r, <vscale x 2 x i32> %x) {
5+
; CHECK-LABEL: @f(
6+
; CHECK-NEXT: entry:
7+
; CHECK-NEXT: [[X_ADDR:%.*]] = alloca <vscale x 2 x i32>, align 8
8+
; CHECK-NEXT: store <vscale x 2 x i32> [[X:%.*]], ptr [[X_ADDR]], align 8
9+
; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr [[X_ADDR]], align 8
10+
; CHECK-NEXT: store i64 [[TMP0]], ptr [[R:%.*]], align 1
11+
; CHECK-NEXT: ret void
12+
;
13+
entry:
14+
%x.addr = alloca <vscale x 2 x i32>, align 8
15+
store <vscale x 2 x i32> %x, ptr %x.addr, align 8
16+
%0 = load i64, ptr %x.addr, align 8
17+
store i64 %0, ptr %r, align 1
18+
ret void
19+
}

0 commit comments

Comments
 (0)