• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -march=avr -mattr=movw,lpmx | FileCheck %s
2; XFAIL: *
3
4# Wide LPM is currently unimplemented in the pseudo expansion pass.
5
6; Tests the extended LPM instructions (LPMW, LPM Rd, Z+).
7
8define i8 @test8(i8 addrspace(1)* %p) {
9; CHECK-LABEL: test8:
10; CHECK: movw r30, r24
11; CHECK: lpm r24, Z
12  %1 = load i8, i8 addrspace(1)* %p
13  ret i8 %1
14}
15
16define i16 @test16(i16 addrspace(1)* %p) {
17; CHECK-LABEL: test16:
18; CHECK: movw r30, r24
19; CHECK: lpmw r24, Z
20  %1 = load i16, i16 addrspace(1)* %p
21  ret i16 %1
22}
23
24define i8 @test8postinc(i8 addrspace(1)* %x, i8 %y) {
25; CHECK-LABEL: test8postinc:
26; CHECK: movw r30, r24
27; CHECK: lpm {{.*}}, Z+
28entry:
29  %cmp10 = icmp sgt i8 %y, 0
30  br i1 %cmp10, label %for.body, label %for.end
31
32for.body:                                         ; preds = %entry, %for.body
33  %ret.013 = phi i8 [ %add, %for.body ], [ 0, %entry ]
34  %i.012 = phi i8 [ %inc, %for.body ], [ 0, %entry ]
35  %x.addr.011 = phi i8 addrspace(1)* [ %incdec.ptr, %for.body ], [ %x, %entry ]
36  %incdec.ptr = getelementptr inbounds i8, i8 addrspace(1)* %x.addr.011, i16 1
37  %0 = load i8, i8 addrspace(1)* %x.addr.011
38  %add = add i8 %0, %ret.013
39  %inc = add i8 %i.012, 1
40  %exitcond = icmp eq i8 %inc, %y
41  br i1 %exitcond, label %for.end, label %for.body
42
43for.end:                                          ; preds = %for.body, %entry
44  %ret.0.lcssa = phi i8 [ 0, %entry ], [ %add, %for.body ]
45  ret i8 %ret.0.lcssa
46}
47
48define i16 @test16postinc(i16 addrspace(1)* %x, i8 %y) {
49; CHECK-LABEL: test16postinc:
50; CHECK: movw r30, r24
51; CHECK: lpmw {{.*}}, Z+
52entry:
53  %cmp5 = icmp sgt i8 %y, 0
54  br i1 %cmp5, label %for.body, label %for.end
55
56for.body:                                         ; preds = %entry, %for.body
57  %ret.08 = phi i16 [ %add, %for.body ], [ 0, %entry ]
58  %i.07 = phi i8 [ %inc, %for.body ], [ 0, %entry ]
59  %x.addr.06 = phi i16 addrspace(1)* [ %incdec.ptr, %for.body ], [ %x, %entry ]
60  %incdec.ptr = getelementptr inbounds i16, i16 addrspace(1)* %x.addr.06, i16 1
61  %0 = load i16, i16 addrspace(1)* %x.addr.06
62  %add = add nsw i16 %0, %ret.08
63  %inc = add i8 %i.07, 1
64  %exitcond = icmp eq i8 %inc, %y
65  br i1 %exitcond, label %for.end, label %for.body
66
67for.end:                                          ; preds = %for.body, %entry
68  %ret.0.lcssa = phi i16 [ 0, %entry ], [ %add, %for.body ]
69  ret i16 %ret.0.lcssa
70}
71