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