• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=ALL --check-prefix=X64
3; RUN: llc -mtriple=i386-linux-gnu   -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=ALL --check-prefix=X32
4
5define i64 @test_add_i64(i64 %arg1, i64 %arg2) {
6; X64-LABEL: test_add_i64:
7; X64:       # %bb.0:
8; X64-NEXT:    leaq (%rsi,%rdi), %rax
9; X64-NEXT:    retq
10;
11; X32-LABEL: test_add_i64:
12; X32:       # %bb.0:
13; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
14; X32-NEXT:    movl {{[0-9]+}}(%esp), %edx
15; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
16; X32-NEXT:    adcl {{[0-9]+}}(%esp), %edx
17; X32-NEXT:    retl
18  %ret = add i64 %arg1, %arg2
19  ret i64 %ret
20}
21
22define i32 @test_add_i32(i32 %arg1, i32 %arg2) {
23; X64-LABEL: test_add_i32:
24; X64:       # %bb.0:
25; X64-NEXT:    # kill: def $edi killed $edi def $rdi
26; X64-NEXT:    # kill: def $esi killed $esi def $rsi
27; X64-NEXT:    leal (%rsi,%rdi), %eax
28; X64-NEXT:    retq
29;
30; X32-LABEL: test_add_i32:
31; X32:       # %bb.0:
32; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
33; X32-NEXT:    addl {{[0-9]+}}(%esp), %eax
34; X32-NEXT:    retl
35  %ret = add i32 %arg1, %arg2
36  ret i32 %ret
37}
38
39define i16 @test_add_i16(i16 %arg1, i16 %arg2) {
40; X64-LABEL: test_add_i16:
41; X64:       # %bb.0:
42; X64-NEXT:    # kill: def $edi killed $edi def $rdi
43; X64-NEXT:    # kill: def $esi killed $esi def $rsi
44; X64-NEXT:    leal (%rsi,%rdi), %eax
45; X64-NEXT:    # kill: def $ax killed $ax killed $eax
46; X64-NEXT:    retq
47;
48; X32-LABEL: test_add_i16:
49; X32:       # %bb.0:
50; X32-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
51; X32-NEXT:    addw {{[0-9]+}}(%esp), %ax
52; X32-NEXT:    retl
53  %ret = add i16 %arg1, %arg2
54  ret i16 %ret
55}
56
57define i8 @test_add_i8(i8 %arg1, i8 %arg2) {
58; X64-LABEL: test_add_i8:
59; X64:       # %bb.0:
60; X64-NEXT:    addb %dil, %sil
61; X64-NEXT:    movl %esi, %eax
62; X64-NEXT:    retq
63;
64; X32-LABEL: test_add_i8:
65; X32:       # %bb.0:
66; X32-NEXT:    movb {{[0-9]+}}(%esp), %al
67; X32-NEXT:    addb {{[0-9]+}}(%esp), %al
68; X32-NEXT:    retl
69  %ret = add i8 %arg1, %arg2
70  ret i8 %ret
71}
72
73define i32 @test_add_i1(i32 %arg1, i32 %arg2) {
74; X64-LABEL: test_add_i1:
75; X64:       # %bb.0:
76; X64-NEXT:    cmpl %esi, %edi
77; X64-NEXT:    sete %al
78; X64-NEXT:    addb %al, %al
79; X64-NEXT:    movzbl %al, %eax
80; X64-NEXT:    andl $1, %eax
81; X64-NEXT:    retq
82;
83; X32-LABEL: test_add_i1:
84; X32:       # %bb.0:
85; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
86; X32-NEXT:    cmpl %eax, {{[0-9]+}}(%esp)
87; X32-NEXT:    sete %al
88; X32-NEXT:    addb %al, %al
89; X32-NEXT:    movzbl %al, %eax
90; X32-NEXT:    andl $1, %eax
91; X32-NEXT:    retl
92  %c = icmp eq i32 %arg1, %arg2
93  %x = add i1 %c , %c
94  %ret = zext i1 %x to i32
95  ret i32 %ret
96}
97