1 ; RUN: llc < %s -march=avr -mattr=movw,lpmx | FileCheck %s
4 # Wide LPM is currently unimplemented in the pseudo expansion pass.
6 ; Tests the extended LPM instructions (LPMW, LPM Rd, Z+).
8 define i8 @test8(i8 addrspace(1)* %p) {
10 ; CHECK: movw r30, r24
12 %1 = load i8, i8 addrspace(1)* %p
16 define i16 @test16(i16 addrspace(1)* %p) {
17 ; CHECK-LABEL: test16:
18 ; CHECK: movw r30, r24
20 %1 = load i16, i16 addrspace(1)* %p
24 define i8 @test8postinc(i8 addrspace(1)* %x, i8 %y) {
25 ; CHECK-LABEL: test8postinc:
26 ; CHECK: movw r30, r24
27 ; CHECK: lpm {{.*}}, Z+
29 %cmp10 = icmp sgt i8 %y, 0
30 br i1 %cmp10, label %for.body, label %for.end
32 for.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
43 for.end: ; preds = %for.body, %entry
44 %ret.0.lcssa = phi i8 [ 0, %entry ], [ %add, %for.body ]
48 define i16 @test16postinc(i16 addrspace(1)* %x, i8 %y) {
49 ; CHECK-LABEL: test16postinc:
50 ; CHECK: movw r30, r24
51 ; CHECK: lpmw {{.*}}, Z+
53 %cmp5 = icmp sgt i8 %y, 0
54 br i1 %cmp5, label %for.body, label %for.end
56 for.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
67 for.end: ; preds = %for.body, %entry
68 %ret.0.lcssa = phi i16 [ 0, %entry ], [ %add, %for.body ]