1 ; RUN: llc < %s -march=avr -mattr=movw,lpm | FileCheck %s
4 ; Tests the standard LPM instruction
6 define i8 @test8(ptr addrspace(1) %p) {
10 %1 = load i8, ptr addrspace(1) %p
14 define i16 @test16(ptr addrspace(1) %p) {
15 ; CHECK-LABEL: test16:
16 ; CHECK: movw r30, r24
19 %1 = load i16, ptr addrspace(1) %p
23 define i8 @test8postinc(ptr addrspace(1) %x, i8 %y) {
24 ; CHECK-LABEL: test8postinc:
25 ; CHECK: movw r30, r24
26 ; CHECK: lpm {{.*}}, Z+
28 %cmp10 = icmp sgt i8 %y, 0
29 br i1 %cmp10, label %for.body, label %for.end
31 for.body: ; preds = %entry, %for.body
32 %ret.013 = phi i8 [ %add, %for.body ], [ 0, %entry ]
33 %i.012 = phi i8 [ %inc, %for.body ], [ 0, %entry ]
34 %x.addr.011 = phi ptr addrspace(1) [ %incdec.ptr, %for.body ], [ %x, %entry ]
35 %incdec.ptr = getelementptr inbounds i8, ptr addrspace(1) %x.addr.011, i16 1
36 %0 = load i8, ptr addrspace(1) %x.addr.011
37 %add = add i8 %0, %ret.013
38 %inc = add i8 %i.012, 1
39 %exitcond = icmp eq i8 %inc, %y
40 br i1 %exitcond, label %for.end, label %for.body
42 for.end: ; preds = %for.body, %entry
43 %ret.0.lcssa = phi i8 [ 0, %entry ], [ %add, %for.body ]
47 define i16 @test16postinc(ptr addrspace(1) %x, i8 %y) {
48 ; CHECK-LABEL: test16postinc:
49 ; CHECK: movw r30, r24
50 ; CHECK: lpm {{.*}}, Z+
51 ; CHECK: lpm {{.*}}, 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 ptr addrspace(1) [ %incdec.ptr, %for.body ], [ %x, %entry ]
60 %incdec.ptr = getelementptr inbounds i16, ptr addrspace(1) %x.addr.06, i16 1
61 %0 = load i16, ptr 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 ]