Skip to content

Commit 0d4778f

Browse files
author
Dylan McKay
committedNov 9, 2016
[AVR] Add a selection of CodeGen tests
Summary: This adds all of the CodeGen tests which currently pass. Reviewers: arsenm, kparzysz Subscribers: japaric, wdng Differential Revision: https://reviews.llvm.org/D26388 llvm-svn: 286418
1 parent 3ffc449 commit 0d4778f

19 files changed

+556
-0
lines changed
 
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; RUN: llc -mattr=avr6 < %s -march=avr | FileCheck %s
2+
3+
; CHECK-LABEL: atomic_load32
4+
; CHECK: call __sync_val_compare_and_swap_4
5+
define i32 @atomic_load32(i32* %foo) {
6+
%val = load atomic i32, i32* %foo unordered, align 4
7+
ret i32 %val
8+
}
9+
10+
; CHECK-LABEL: atomic_load_sub32
11+
; CHECK: call __sync_fetch_and_sub_4
12+
define i32 @atomic_load_sub32(i32* %foo) {
13+
%val = atomicrmw sub i32* %foo, i32 13 seq_cst
14+
ret i32 %val
15+
}
16+
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; RUN: llc -mattr=avr6 < %s -march=avr | FileCheck %s
2+
3+
; CHECK-LABEL: atomic_load64
4+
; CHECK: call __sync_val_compare_and_swap_8
5+
define i64 @atomic_load64(i64* %foo) {
6+
%val = load atomic i64, i64* %foo unordered, align 8
7+
ret i64 %val
8+
}
9+
10+
; CHECK-LABEL: atomic_load_sub64
11+
; CHECK: call __sync_fetch_and_sub_8
12+
define i64 @atomic_load_sub64(i64* %foo) {
13+
%val = atomicrmw sub i64* %foo, i64 13 seq_cst
14+
ret i64 %val
15+
}
16+

‎llvm/test/CodeGen/AVR/atomics/swap.ll

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; RUN: llc -mattr=avr6 < %s -march=avr | FileCheck %s
2+
3+
; CHECK-LABEL: atomic_swap8
4+
; CHECK: call __sync_lock_test_and_set_1
5+
define i8 @atomic_swap8(i8* %foo) {
6+
%val = atomicrmw xchg i8* %foo, i8 13 seq_cst
7+
ret i8 %val
8+
}
9+
10+
; CHECK-LABEL: atomic_swap16
11+
; CHECK: call __sync_lock_test_and_set_2
12+
define i16 @atomic_swap16(i16* %foo) {
13+
%val = atomicrmw xchg i16* %foo, i16 13 seq_cst
14+
ret i16 %val
15+
}
16+
17+
; CHECK-LABEL: atomic_swap32
18+
; CHECK: call __sync_lock_test_and_set_4
19+
define i32 @atomic_swap32(i32* %foo) {
20+
%val = atomicrmw xchg i32* %foo, i32 13 seq_cst
21+
ret i32 %val
22+
}
23+
24+
; CHECK-LABEL: atomic_swap64
25+
; CHECK: call __sync_lock_test_and_set_8
26+
define i64 @atomic_swap64(i64* %foo) {
27+
%val = atomicrmw xchg i64* %foo, i64 13 seq_cst
28+
ret i64 %val
29+
}
30+

‎llvm/test/CodeGen/AVR/ctpop.ll

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; RUN: llc < %s -march=avr | FileCheck %s
2+
3+
define i8 @count_population(i8) unnamed_addr {
4+
entry-block:
5+
%1 = tail call i8 @llvm.ctpop.i8(i8 %0)
6+
ret i8 %1
7+
}
8+
9+
declare i8 @llvm.ctpop.i8(i8)
10+
11+
; CHECK-LABEL: count_population:
12+
; CHECK: mov [[SCRATCH:r[0-9]+]], [[RESULT:r[0-9]+]]
13+
; CHECK: lsr {{.*}}[[SCRATCH]]
14+
; CHECK: andi {{.*}}[[SCRATCH]], 85
15+
; CHECK: sub {{.*}}[[RESULT]], {{.*}}[[SCRATCH]]
16+
; CHECK: mov {{.*}}[[SCRATCH]], {{.*}}[[RESULT]]
17+
; CHECK: andi {{.*}}[[SCRATCH]], 51
18+
; CHECK: lsr {{.*}}[[RESULT]]
19+
; CHECK: lsr {{.*}}[[RESULT]]
20+
; CHECK: andi {{.*}}[[RESULT]], 51
21+
; CHECK: add {{.*}}[[RESULT]], {{.*}}[[SCRATCH]]
22+
; CHECK: mov {{.*}}[[SCRATCH]], {{.*}}[[RESULT]]
23+
; CHECK: lsr {{.*}}[[SCRATCH]]
24+
; CHECK: lsr {{.*}}[[SCRATCH]]
25+
; CHECK: lsr {{.*}}[[SCRATCH]]
26+
; CHECK: lsr {{.*}}[[SCRATCH]]
27+
; CHECK: add {{.*}}[[SCRATCH]], {{.*}}[[RESULT]]
28+
; CHECK: andi {{.*}}[[SCRATCH]], 15
29+
; CHECK: mov {{.*}}[[RESULT]], {{.*}}[[SCRATCH]]
30+
; CHECK: ret

‎llvm/test/CodeGen/AVR/div.ll

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
; RUN: llc -mattr=mul,movw < %s -march=avr | FileCheck %s
2+
3+
; Unsigned 8-bit division
4+
define i8 @udiv8(i8 %a, i8 %b) {
5+
; CHECK-LABEL: div8:
6+
; CHECK: call __udivmodqi4
7+
; CHECK-NEXT: ret
8+
9+
%quotient = udiv i8 %a, %b
10+
ret i8 %quotient
11+
}
12+
13+
; Signed 8-bit division
14+
define i8 @sdiv8(i8 %a, i8 %b) {
15+
; CHECK-LABEL: sdiv8:
16+
; CHECK: call __divmodqi4
17+
; CHECK-NEXT: ret
18+
19+
%quotient = sdiv i8 %a, %b
20+
ret i8 %quotient
21+
}
22+
23+
; Unsigned 16-bit division
24+
define i16 @udiv16(i16 %a, i16 %b) {
25+
; CHECK-LABEL: udiv16:
26+
; CHECK: call __udivmodhi4
27+
; CHECK-NEXT: movw r24, r22
28+
; CHECK-NEXT: ret
29+
%quot = udiv i16 %a, %b
30+
ret i16 %quot
31+
}
32+
33+
; Signed 16-bit division
34+
define i16 @sdiv16(i16 %a, i16 %b) {
35+
; CHECK-LABEL: sdiv16:
36+
; CHECK: call __divmodhi4
37+
; CHECK-NEXT: movw r24, r22
38+
; CHECK-NEXT: ret
39+
%quot = sdiv i16 %a, %b
40+
ret i16 %quot
41+
}
42+
43+
; Unsigned 32-bit division
44+
define i32 @udiv32(i32 %a, i32 %b) {
45+
; CHECK-LABEL: udiv32:
46+
; CHECK: call __udivmodsi4
47+
; CHECK-NEXT: movw r22, r18
48+
; CHECK-NEXT: movw r24, r20
49+
; CHECK-NEXT: ret
50+
%quot = udiv i32 %a, %b
51+
ret i32 %quot
52+
}
53+
54+
; Signed 32-bit division
55+
define i32 @sdiv32(i32 %a, i32 %b) {
56+
; CHECK-LABEL: sdiv32:
57+
; CHECK: call __divmodsi4
58+
; CHECK-NEXT: movw r22, r18
59+
; CHECK-NEXT: movw r24, r20
60+
; CHECK-NEXT: ret
61+
%quot = sdiv i32 %a, %b
62+
ret i32 %quot
63+
}
64+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: llc -mattr=avrtiny -O0 < %s -march=avr | FileCheck %s
2+
3+
define i16 @reg_copy16(i16 %a) {
4+
; CHECK-LABEL: reg_copy16
5+
; CHECK: mov r18, r24
6+
; CHECK: mov r19, r25
7+
8+
ret i16 %a
9+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; RUN: llc -mattr=avr25 -O0 < %s -march=avr | FileCheck %s
2+
3+
; On most cores, the 16-bit 'MOVW' instruction can be used
4+
define i16 @reg_copy16(i16 %a) {
5+
; CHECK-LABEL: reg_copy16
6+
; CHECK: movw r18, r24
7+
ret i16 %a
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; RUN: llc < %s -march=avr | FileCheck %s
2+
3+
; Test case for an assertion error.
4+
;
5+
; Error:
6+
; ```
7+
; Impossible reg-to-reg copy
8+
; UNREACHABLE executed at lib/Target/AVR/AVRInstrInfo.cpp
9+
; ```
10+
;
11+
; This no longer occurs.
12+
13+
declare { i16, i1 } @llvm.umul.with.overflow.i16(i16, i16)
14+
15+
; CHECK-LABEL: foo
16+
define void @foo() {
17+
entry-block:
18+
%0 = call { i16, i1 } @llvm.umul.with.overflow.i16(i16 undef, i16 undef)
19+
%1 = extractvalue { i16, i1 } %0, 1
20+
%2 = icmp eq i1 %1, true
21+
br i1 %2, label %cond, label %next
22+
23+
next: ; preds = %entry-block
24+
ret void
25+
cond: ; preds = %entry-block
26+
unreachable
27+
}

‎llvm/test/CodeGen/AVR/inline-asm2.ll

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; RUN: llc < %s -march=avr | FileCheck %s
2+
3+
; CHECK-LABEL: foo
4+
define void @foo(i16 %a) {
5+
call void asm sideeffect "add $0, $0", "Z"(i16 %a) nounwind
6+
ret void
7+
}
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; RUN: llc < %s -march=avr | FileCheck %s
2+
3+
declare i16 @llvm.bswap.i16(i16)
4+
5+
define i16 @foo(i16) {
6+
; CHECK-LABEL: foo:
7+
entry-block:
8+
%1 = tail call i16 @llvm.bswap.i16(i16 %0)
9+
ret i16 %1
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
; RUN: llc < %s -march=avr | FileCheck %s
2+
3+
define void @foo(i1) {
4+
; CHECK-LABEL: foo:
5+
; CHECK: ret
6+
ret void
7+
}

‎llvm/test/CodeGen/AVR/mul.ll

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; RUN: llc -mattr=mul,movw < %s -march=avr | FileCheck %s
2+
3+
define i8 @mult8(i8 %a, i8 %b) {
4+
; CHECK-LABEL: mult8:
5+
; CHECK: muls r22, r24
6+
; CHECK: eor r1, r1
7+
; CHECK: mov r24, r0
8+
%mul = mul i8 %b, %a
9+
ret i8 %mul
10+
}
11+
12+
define i16 @mult16(i16 %a, i16 %b) {
13+
; CHECK-LABEL: mult16:
14+
; CHECK: muls r22, r25
15+
; CHECK: mov r18, r0
16+
; CHECK: mul r22, r24
17+
; CHECK: mov r19, r0
18+
; CHECK: mov r20, r1
19+
; CHECK: eor r1, r1
20+
; CHECK: add r20, r18
21+
; CHECK: muls r23, r24
22+
; CHECK: eor r1, r1
23+
; CHECK: mov r22, r0
24+
; CHECK: add r22, r20
25+
; :TODO: finish after reworking shift instructions
26+
%mul = mul nsw i16 %b, %a
27+
ret i16 %mul
28+
}

‎llvm/test/CodeGen/AVR/neg.ll

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; RUN: llc < %s -march=avr | FileCheck %s
2+
3+
define i8 @neg8(i8 %x) {
4+
; CHECK-LABEL: neg8:
5+
; CHECK: neg r24
6+
%sub = sub i8 0, %x
7+
ret i8 %sub
8+
}
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
}

‎llvm/test/CodeGen/AVR/rem.ll

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
; RUN: llc -mattr=mul,movw < %s -march=avr | FileCheck %s
2+
3+
; Unsigned 8-bit remision
4+
define i8 @urem8(i8 %a, i8 %b) {
5+
; CHECK-LABEL: rem8:
6+
; CHECK: call __udivmodqi4
7+
; CHECK-NEXT: mov r24, r25
8+
; CHECK-NEXT: ret
9+
%rem = urem i8 %a, %b
10+
ret i8 %rem
11+
}
12+
13+
; Signed 8-bit remision
14+
define i8 @srem8(i8 %a, i8 %b) {
15+
; CHECK-LABEL: srem8:
16+
; CHECK: call __divmodqi4
17+
; CHECK-NEXT: mov r24, r25
18+
; CHECK-NEXT: ret
19+
%rem = srem i8 %a, %b
20+
ret i8 %rem
21+
}
22+
23+
; Unsigned 16-bit remision
24+
define i16 @urem16(i16 %a, i16 %b) {
25+
; CHECK-LABEL: urem16:
26+
; CHECK: call __udivmodhi4
27+
; CHECK-NEXT: ret
28+
%rem = urem i16 %a, %b
29+
ret i16 %rem
30+
}
31+
32+
; Signed 16-bit remision
33+
define i16 @srem16(i16 %a, i16 %b) {
34+
; CHECK-LABEL: srem16:
35+
; CHECK: call __divmodhi4
36+
; CHECK-NEXT: ret
37+
%rem = srem i16 %a, %b
38+
ret i16 %rem
39+
}
40+
41+
; Unsigned 32-bit remision
42+
define i32 @urem32(i32 %a, i32 %b) {
43+
; CHECK-LABEL: urem32:
44+
; CHECK: call __udivmodsi4
45+
; CHECK-NEXT: ret
46+
%rem = urem i32 %a, %b
47+
ret i32 %rem
48+
}
49+
50+
; Signed 32-bit remision
51+
define i32 @srem32(i32 %a, i32 %b) {
52+
; CHECK-LABEL: srem32:
53+
; CHECK: call __divmodsi4
54+
; CHECK-NEXT: ret
55+
%rem = srem i32 %a, %b
56+
ret i32 %rem
57+
}
58+

‎llvm/test/CodeGen/AVR/runtime-trig.ll

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; RUN: llc < %s -march=avr | FileCheck %s
2+
3+
; Checks that `sin` and `cos` nodes are expanded into calls to
4+
; the `sin` and `cos` runtime library functions.
5+
; On AVR, the only floats supported are 32-bits, and so the
6+
; function names have no `f` or `d` suffix.
7+
8+
declare float @llvm.sin.f32(float %x)
9+
declare float @llvm.cos.f32(float %x)
10+
11+
define float @do_sin(float %a) {
12+
; CHECK-LABEL: do_sin:
13+
; CHECK: {{sin$}}
14+
%result = call float @llvm.sin.f32(float %a)
15+
ret float %result
16+
}
17+
18+
; CHECK-LABEL: do_cos:
19+
; CHECK: {{cos$}}
20+
define float @do_cos(float %a) {
21+
%result = call float @llvm.cos.f32(float %a)
22+
ret float %result
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
; RUN: llc -march=avr -print-after=expand-isel-pseudos < %s 2>&1 | FileCheck %s
2+
3+
; Because `switch` seems to trigger Machine Basic Blocks to be ordered
4+
; in a different order than they were constructed, this exposes an
5+
; error in the `expand-isel-pseudos` pass. Specifically, it thought we
6+
; could always fallthrough to a newly-constructed MBB. However,
7+
; there's no guarantee that either of the constructed MBBs need to
8+
; occur immediately after the currently-focused one!
9+
;
10+
; This issue manifests in a CFG that looks something like this:
11+
;
12+
; BB#2: derived from LLVM BB %finish
13+
; Predecessors according to CFG: BB#0 BB#1
14+
; %vreg0<def> = PHI %vreg3, <BB#0>, %vreg5, <BB#1>
15+
; %vreg7<def> = LDIRdK 2
16+
; %vreg8<def> = LDIRdK 1
17+
; CPRdRr %vreg2, %vreg0, %SREG<imp-def>
18+
; BREQk <BB#6>, %SREG<imp-use>
19+
; Successors according to CFG: BB#5(?%) BB#6(?%)
20+
;
21+
; The code assumes it the fallthrough block after this is BB#5, but
22+
; it's actually BB#3! To be proper, there should be an unconditional
23+
; jump tying this block to BB#5.
24+
25+
define i8 @select_must_add_unconditional_jump(i8 %arg0, i8 %arg1) unnamed_addr {
26+
entry-block:
27+
switch i8 %arg0, label %dead [
28+
i8 0, label %zero
29+
i8 1, label %one
30+
]
31+
32+
zero:
33+
br label %finish
34+
35+
one:
36+
br label %finish
37+
38+
finish:
39+
%predicate = phi i8 [ 50, %zero ], [ 100, %one ]
40+
%is_eq = icmp eq i8 %arg1, %predicate
41+
%result = select i1 %is_eq, i8 1, i8 2
42+
ret i8 %result
43+
44+
dead:
45+
ret i8 0
46+
}
47+
48+
; This check may be a bit brittle, but the important thing is that the
49+
; basic block containing `select` needs to contain explicit jumps to
50+
; both successors.
51+
52+
; CHECK: BB#2: derived from LLVM BB %finish
53+
; CHECK: BREQk <[[BRANCHED:BB#[0-9]+]]>
54+
; CHECK: RJMPk <[[DIRECT:BB#[0-9]+]]>
55+
; CHECK: Successors according to CFG
56+
; CHECK-SAME-DAG: {{.*}}[[BRANCHED]]
57+
; CHECK-SAME-DAG: {{.*}}[[DIRECT]]
58+
; CHECK: BB#3: derived from LLVM BB
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
; RUN: llc -march=avr < %s | FileCheck %s
2+
3+
define i8 @sign_extended_1_to_8(i1) {
4+
; CHECK-LABEL: sign_extended_1_to_8
5+
entry-block:
6+
%1 = sext i1 %0 to i8
7+
ret i8 %1
8+
}
9+
10+
define i16 @sign_extended_1_to_16(i1) {
11+
; CHECK-LABEL: sign_extended_1_to_16
12+
entry-block:
13+
%1 = sext i1 %0 to i16
14+
ret i16 %1
15+
}
16+
17+
define i16 @sign_extended_8_to_16(i8) {
18+
; CHECK-LABEL: sign_extended_8_to_16
19+
entry-block:
20+
%1 = sext i8 %0 to i16
21+
ret i16 %1
22+
}
23+
24+
define i32 @sign_extended_1_to_32(i1) {
25+
; CHECK-LABEL: sign_extended_1_to_32
26+
entry-block:
27+
%1 = sext i1 %0 to i32
28+
ret i32 %1
29+
}
30+
31+
define i32 @sign_extended_8_to_32(i8) {
32+
; CHECK-LABEL: sign_extended_8_to_32
33+
entry-block:
34+
%1 = sext i8 %0 to i32
35+
ret i32 %1
36+
}
37+
38+
define i32 @sign_extended_16_to_32(i16) {
39+
; CHECK-LABEL: sign_extended_16_to_32
40+
entry-block:
41+
%1 = sext i16 %0 to i32
42+
ret i32 %1
43+
}
44+
45+
define i64 @sign_extended_1_to_64(i1) {
46+
; CHECK-LABEL: sign_extended_1_to_64
47+
entry-block:
48+
%1 = sext i1 %0 to i64
49+
ret i64 %1
50+
}
51+
52+
define i64 @sign_extended_8_to_64(i8) {
53+
; CHECK-LABEL: sign_extended_8_to_64
54+
entry-block:
55+
%1 = sext i8 %0 to i64
56+
ret i64 %1
57+
}
58+
59+
define i64 @sign_extended_16_to_64(i16) {
60+
; CHECK-LABEL: sign_extended_16_to_64
61+
entry-block:
62+
%1 = sext i16 %0 to i64
63+
ret i64 %1
64+
}
65+
66+
define i64 @sign_extended_32_to_64(i32) {
67+
; CHECK-LABEL: sign_extended_32_to_64
68+
entry-block:
69+
%1 = sext i32 %0 to i64
70+
ret i64 %1
71+
}

‎llvm/test/CodeGen/AVR/trunc.ll

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; RUN: llc < %s -march=avr | FileCheck %s
2+
3+
define i8 @trunc8_loreg(i16 %x, i16 %y) {
4+
; CHECK-LABEL: trunc8_loreg:
5+
; CHECK: mov r24, r22
6+
; CHECK-NEXT: ret
7+
%conv = trunc i16 %y to i8
8+
ret i8 %conv
9+
}
10+
11+
define i8 @trunc8_hireg(i16 %x, i16 %y) {
12+
; CHECK-LABEL: trunc8_hireg:
13+
; CHECK: mov r24, r23
14+
; CHECK-NEXT: ret
15+
%shr1 = lshr i16 %y, 8
16+
%conv = trunc i16 %shr1 to i8
17+
ret i8 %conv
18+
}

0 commit comments

Comments
 (0)
Please sign in to comment.