1; RUN: llc < %s -march=avr -mattr=movw,lpm | FileCheck %s 2; XFAIL: * 3 4; Tests the standard LPM instruction 5 6define i8 @test8(i8 addrspace(1)* %p) { 7; CHECK-LABEL: test8: 8; CHECK: movw r30, r24 9; CHECK: lpm r24, Z 10 %1 = load i8, i8 addrspace(1)* %p 11 ret i8 %1 12} 13 14define i16 @test16(i16 addrspace(1)* %p) { 15; CHECK-LABEL: test16: 16; CHECK: movw r30, r24 17; CHECK: lpm r24, Z+ 18; CHECK: lpm r25, Z+ 19 %1 = load i16, i16 addrspace(1)* %p 20 ret i16 %1 21} 22 23define i8 @test8postinc(i8 addrspace(1)* %x, i8 %y) { 24; CHECK-LABEL: test8postinc: 25; CHECK: movw r30, r24 26; CHECK: lpm {{.*}}, Z+ 27entry: 28 %cmp10 = icmp sgt i8 %y, 0 29 br i1 %cmp10, label %for.body, label %for.end 30 31for.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 i8 addrspace(1)* [ %incdec.ptr, %for.body ], [ %x, %entry ] 35 %incdec.ptr = getelementptr inbounds i8, i8 addrspace(1)* %x.addr.011, i16 1 36 %0 = load i8, i8 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 41 42for.end: ; preds = %for.body, %entry 43 %ret.0.lcssa = phi i8 [ 0, %entry ], [ %add, %for.body ] 44 ret i8 %ret.0.lcssa 45} 46 47define i16 @test16postinc(i16 addrspace(1)* %x, i8 %y) { 48; CHECK-LABEL: test16postinc: 49; CHECK: movw r30, r24 50; CHECK: lpm {{.*}}, Z+ 51; CHECK: lpm {{.*}}, 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