xref: /llvm-project/llvm/test/CodeGen/AArch64/aarch64-p2align-max-bytes.ll (revision 1ee315ae7964c8433b772e0b5d667834994ba753)
1; RUN: llc -mtriple=aarch64-none-linux-gnu -max-bytes-for-alignment=8 --align-loops=32 < %s -o -| FileCheck %s --check-prefixes=CHECK,CHECK-EXPLICIT
2; RUN: llc -mtriple=aarch64-none-linux-gnu --align-loops=32 < %s -o -| FileCheck %s --check-prefixes=CHECK,CHECK-IMPLICIT
3; RUN: llc -mtriple=aarch64-none-linux-gnu --align-loops=32 < %s -o - --filetype=obj | llvm-objdump --arch=aarch64  -d -| FileCheck %s --check-prefixes=CHECK-OBJ,CHECK-OBJ-IMPLICIT
4; RUN: llc -mtriple=aarch64-none-linux-gnu -max-bytes-for-alignment=8 --align-loops=32 < %s -o - --filetype=obj | llvm-objdump --arch=aarch64  -d -| FileCheck %s --check-prefixes=CHECK-OBJ,CHECK-OBJ-EXPLICIT
5
6; This test is checking that the correct operands to the .p2align are emitted correctly, and that the resulting obj
7; is padded as expected. The key interest in the CHECK-OBJ-* sections is the size of the padding region (the nops),
8; and not the exact instructions either side of them (But the last instruction of the EXPLICIT and IMPLICIT checks
9; should be the same, at different locations)
10define i32 @a(i32 %x, ptr nocapture readonly %y, ptr nocapture readonly %z) {
11; CHECK-LABEL: a:
12; CHECK-EXPLICIT:    .p2align 5, , 8
13; CHECK-IMPLICIT:    .p2align 5
14; CHECK-NEXT:  .LBB0_5: // %vector.body
15; CHECK-EXPLICIT:    .p2align 5, , 8
16; CHECK-IMPLICIT:    .p2align 5
17; CHECK-NEXT:  .LBB0_8: // %for.body
18; CHECK-OBJ;Disassembly of section .text:
19; CHECK-OBJ:               88: 8b0a002a      add
20; CHECK-OBJ-IMPLICIT-NEXT: 8c: d503201f      nop
21; CHECK-OBJ-IMPLICIT-NEXT: 90: d503201f      nop
22; CHECK-OBJ-IMPLICIT-NEXT: 94: d503201f      nop
23; CHECK-OBJ-IMPLICIT-NEXT: 98: d503201f      nop
24; CHECK-OBJ-IMPLICIT-NEXT: 9c: d503201f      nop
25; CHECK-OBJ-IMPLICIT-NEXT: a0: b840454b      ldr
26; CHECK-OBJ-EXPLICIT-NEXT: 8c: b840454b      ldr
27entry:
28  %cmp10 = icmp sgt i32 %x, 0
29  br i1 %cmp10, label %for.body.preheader, label %for.cond.cleanup
30
31for.body.preheader:                               ; preds = %entry
32  %wide.trip.count = zext i32 %x to i64
33  %min.iters.check = icmp ult i32 %x, 8
34  br i1 %min.iters.check, label %for.body.preheader17, label %vector.ph
35
36vector.ph:                                        ; preds = %for.body.preheader
37  %n.vec = and i64 %wide.trip.count, 4294967288
38  br label %vector.body
39
40vector.body:                                      ; preds = %vector.body, %vector.ph
41  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
42  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %10, %vector.body ]
43  %vec.phi13 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %11, %vector.body ]
44  %0 = getelementptr inbounds i32, ptr %y, i64 %index
45  %1 = bitcast ptr %0 to ptr
46  %wide.load = load <4 x i32>, ptr %1, align 4
47  %2 = getelementptr inbounds i32, ptr %0, i64 4
48  %3 = bitcast ptr %2 to ptr
49  %wide.load14 = load <4 x i32>, ptr %3, align 4
50  %4 = getelementptr inbounds i32, ptr %z, i64 %index
51  %5 = bitcast ptr %4 to ptr
52  %wide.load15 = load <4 x i32>, ptr %5, align 4
53  %6 = getelementptr inbounds i32, ptr %4, i64 4
54  %7 = bitcast ptr %6 to ptr
55  %wide.load16 = load <4 x i32>, ptr %7, align 4
56  %8 = add <4 x i32> %wide.load, %vec.phi
57  %9 = add <4 x i32> %wide.load14, %vec.phi13
58  %10 = add <4 x i32> %8, %wide.load15
59  %11 = add <4 x i32> %9, %wide.load16
60  %index.next = add nuw i64 %index, 8
61  %12 = icmp eq i64 %index.next, %n.vec
62  br i1 %12, label %middle.block, label %vector.body
63
64middle.block:                                     ; preds = %vector.body
65  %bin.rdx = add <4 x i32> %11, %10
66  %13 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
67  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
68  br i1 %cmp.n, label %for.cond.cleanup, label %for.body.preheader17
69
70for.body.preheader17:                             ; preds = %for.body.preheader, %middle.block
71  %indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
72  %b.011.ph = phi i32 [ 0, %for.body.preheader ], [ %13, %middle.block ]
73  br label %for.body
74
75for.cond.cleanup:                                 ; preds = %for.body, %middle.block, %entry
76  %b.0.lcssa = phi i32 [ 0, %entry ], [ %13, %middle.block ], [ %add3, %for.body ]
77  ret i32 %b.0.lcssa
78
79for.body:                                         ; preds = %for.body.preheader17, %for.body
80  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader17 ]
81  %b.011 = phi i32 [ %add3, %for.body ], [ %b.011.ph, %for.body.preheader17 ]
82  %arrayidx = getelementptr inbounds i32, ptr %y, i64 %indvars.iv
83  %14 = load i32, ptr %arrayidx, align 4
84  %arrayidx2 = getelementptr inbounds i32, ptr %z, i64 %indvars.iv
85  %15 = load i32, ptr %arrayidx2, align 4
86  %add = add i32 %14, %b.011
87  %add3 = add i32 %add, %15
88  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
89  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
90  br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
91}
92
93declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>)
94