Skip to content

Commit 50d6579

Browse files
committed
GlobalISel: Fix MMO creation with non-power-of-2 mem size
It should probably just be mandatory for getTgtMemIntrinsic to return the alignment. llvm-svn: 352817
1 parent 886b7cc commit 50d6579

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,12 +1213,13 @@ bool IRTranslator::translateCall(const User &U, MachineIRBuilder &MIRBuilder) {
12131213
TargetLowering::IntrinsicInfo Info;
12141214
// TODO: Add a GlobalISel version of getTgtMemIntrinsic.
12151215
if (TLI.getTgtMemIntrinsic(Info, CI, *MF, ID)) {
1216-
uint64_t Size = Info.memVT.getStoreSize();
1217-
if (Info.align == 0)
1218-
Info.align = Size;
1216+
unsigned Align = Info.align;
1217+
if (Align == 0)
1218+
Align = DL->getABITypeAlignment(Info.memVT.getTypeForEVT(F->getContext()));
12191219

1220+
uint64_t Size = Info.memVT.getStoreSize();
12201221
MIB.addMemOperand(MF->getMachineMemOperand(MachinePointerInfo(Info.ptrVal),
1221-
Info.flags, Size, Info.align));
1222+
Info.flags, Size, Align));
12221223
}
12231224

12241225
return true;

llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,3 +2323,12 @@ define float @test_sqrt_f32(float %x) {
23232323
%y = call float @llvm.sqrt.f32(float %x)
23242324
ret float %y
23252325
}
2326+
2327+
; CHECK-LABEL: name: test_llvm.aarch64.neon.ld3.v4i32.p0i32
2328+
; CHECK: %1:_(s384) = G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.aarch64.neon.ld3), %0(p0) :: (load 48 from %ir.ptr, align 64)
2329+
define void @test_llvm.aarch64.neon.ld3.v4i32.p0i32(i32* %ptr) {
2330+
%arst = call { <4 x i32>, <4 x i32>, <4 x i32> } @llvm.aarch64.neon.ld3.v4i32.p0i32(i32* %ptr)
2331+
ret void
2332+
}
2333+
2334+
declare { <4 x i32>, <4 x i32>, <4 x i32> } @llvm.aarch64.neon.ld3.v4i32.p0i32(i32*) #3

0 commit comments

Comments
 (0)