1 ; RUN: opt < %s -S -aarch64-falkor-hwpf-fix -mtriple aarch64 -mcpu=falkor | FileCheck %s
2 ; RUN: opt < %s -S -aarch64-falkor-hwpf-fix -mtriple aarch64 -mcpu=cortex-a57 | FileCheck %s --check-prefix=NOHWPF
4 ; Check that strided access metadata is added to loads in inner loops when compiling for Falkor.
7 ; CHECK: load i32, ptr %gep, align 4, !falkor.strided.access !0
8 ; CHECK: load i32, ptr %gep2, align 4, !falkor.strided.access !0
10 ; NOHWPF-LABEL: @hwpf1(
11 ; NOHWPF: load i32, ptr %gep, align 4{{$}}
12 ; NOHWPF: load i32, ptr %gep2, align 4{{$}}
13 define void @hwpf1(ptr %p, ptr %p2) {
18 %iv = phi i32 [ 0, %entry ], [ %inc, %loop ]
20 %gep = getelementptr inbounds i32, ptr %p, i32 %iv
21 %load = load i32, ptr %gep
23 %gep2 = getelementptr inbounds i32, ptr %p2, i32 %iv
24 %load2 = load i32, ptr %gep2
27 %exitcnd = icmp uge i32 %inc, 1024
28 br i1 %exitcnd, label %exit, label %loop
34 ; Check that outer loop strided load isn't marked.
35 ; CHECK-LABEL: @hwpf2(
36 ; CHECK: load i32, ptr %gep, align 4, !falkor.strided.access !0
37 ; CHECK: load i32, ptr %gep2, align 4{{$}}
39 ; NOHWPF-LABEL: @hwpf2(
40 ; NOHWPF: load i32, ptr %gep, align 4{{$}}
41 ; NOHWPF: load i32, ptr %gep2, align 4{{$}}
42 define void @hwpf2(ptr %p) {
47 %iv1 = phi i32 [ 0, %entry ], [ %inc1, %loop1.latch ]
48 %outer.sum = phi i32 [ 0, %entry ], [ %sum, %loop1.latch ]
49 br label %loop2.header
55 %iv2 = phi i32 [ 0, %loop2.header ], [ %inc2, %loop2 ]
56 %sum = phi i32 [ %outer.sum, %loop2.header ], [ %sum.inc, %loop2 ]
57 %gep = getelementptr inbounds i32, ptr %p, i32 %iv2
58 %load = load i32, ptr %gep
59 %sum.inc = add i32 %sum, %load
60 %inc2 = add i32 %iv2, 1
61 %exitcnd2 = icmp uge i32 %inc2, 1024
62 br i1 %exitcnd2, label %exit2, label %loop2
65 %gep2 = getelementptr inbounds i32, ptr %p, i32 %iv1
66 %load2 = load i32, ptr %gep2
70 %inc1 = add i32 %iv1, 1
71 %exitcnd1 = icmp uge i32 %inc1, 1024
72 br i1 %exitcnd2, label %exit, label %loop1
79 ; Check that non-strided load isn't marked.
80 ; CHECK-LABEL: @hwpf3(
81 ; CHECK: load i32, ptr %gep, align 4, !falkor.strided.access !0
82 ; CHECK: load i32, ptr %gep2, align 4{{$}}
84 ; NOHWPF-LABEL: @hwpf3(
85 ; NOHWPF: load i32, ptr %gep, align 4{{$}}
86 ; NOHWPF: load i32, ptr %gep2, align 4{{$}}
87 define void @hwpf3(ptr %p, ptr %p2) {
92 %iv = phi i32 [ 0, %entry ], [ %inc, %loop ]
94 %gep = getelementptr inbounds i32, ptr %p, i32 %iv
95 %load = load i32, ptr %gep
97 %gep2 = getelementptr inbounds i32, ptr %p2, i32 %load
98 %load2 = load i32, ptr %gep2
100 %inc = add i32 %iv, 1
101 %exitcnd = icmp uge i32 %inc, 1024
102 br i1 %exitcnd, label %exit, label %loop