xref: /llvm-project/llvm/test/CodeGen/PowerPC/lxv-aligned-stack-slots.ll (revision 427fb35192f1f7bb694a5910b05abc5925a798b2)
1; RUN: llc -O3 -ppc-late-peephole=false -ppc-convert-rr-to-ri=false -o - %s | FileCheck %s
2target datalayout = "e-m:e-i64:64-n32:64"
3target triple = "powerpc64le-unknown-linux-gnu"
4
5%class1 = type { %union1 }
6%union1 = type { i64, [24 x i8] }
7%class2 = type { %class3 }
8%class3 = type { %class4 }
9%class4 = type { %class5, i64, %union.anon }
10%class5 = type { ptr }
11%union.anon = type { i64, [8 x i8] }
12
13@ext = external global %"class1", align 8
14
15; We can't select lxv for this because even though we're accessing an offset of
16; 16 from the stack slot, the stack slot is only guaranteed to be 8-byte
17; aligned. When the frame is finalized it is converted to lxv (frame-reg) +
18; (offset + 16). Because offset isn't guaranteed to be 16-byte aligned, we may
19; end up needing to translate the lxv instruction to lxvx
20; CHECK-LABEL: unaligned_slot:
21; CHECK-NOT: lxv {{[0-9]+}}, {{[-0-9]+}}({{[0-9]+}})
22; CHECK: blr
23define void @unaligned_slot() #0 {
24  %1 = alloca %class2, align 8
25  %2 = getelementptr inbounds %class2, ptr %1, i64 0, i32 0, i32 0, i32 2
26  call void @llvm.memcpy.p0.p0.i64(ptr align 8 nonnull getelementptr inbounds (%class1, ptr @ext, i64 0, i32 0, i32 1, i64 8), ptr align 8 nonnull %2, i64 16, i1 false) #2
27  ret void
28}
29; CHECK-LABEL: aligned_slot:
30; CHECK: lxv {{[0-9]+}}, {{[-0-9]+}}({{[0-9]+}})
31; CHECK: blr
32define void @aligned_slot() #0 {
33  %1 = alloca %class2, align 16
34  %2 = getelementptr inbounds %class2, ptr %1, i64 0, i32 0, i32 0, i32 2
35  call void @llvm.memcpy.p0.p0.i64(ptr align 8 nonnull getelementptr inbounds (%class1, ptr @ext, i64 0, i32 0, i32 1, i64 8), ptr align 8 nonnull %2, i64 16, i1 false) #2
36  ret void
37}
38
39; Function Attrs: argmemonly nounwind
40declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1) #1
41
42attributes #0 = { nounwind "target-cpu"="pwr9" "target-features"="+altivec,+bpermd,+crypto,+direct-move,+extdiv,+htm,+power8-vector,+power9-vector,+vsx" "unsafe-fp-math"="false" "use-soft-float"="false" }
43attributes #1 = { argmemonly nounwind }
44attributes #2 = { nounwind }
45