• 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 -global-isel-abort=2 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X64
3; RUN: llc -mtriple=i386-linux-gnu   -global-isel -global-isel-abort=2 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X86
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; X86-LABEL: test_add_i64:
12; X86:       # %bb.0:
13; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
14; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
15; X86-NEXT:    addl {{[0-9]+}}(%esp), %eax
16; X86-NEXT:    adcl {{[0-9]+}}(%esp), %edx
17; X86-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; X86-LABEL: test_add_i32:
31; X86:       # %bb.0:
32; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
33; X86-NEXT:    addl {{[0-9]+}}(%esp), %eax
34; X86-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; X86-LABEL: test_add_i16:
49; X86:       # %bb.0:
50; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
51; X86-NEXT:    addw {{[0-9]+}}(%esp), %ax
52; X86-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:    # kill: def $edi killed $edi def $rdi
61; X64-NEXT:    # kill: def $esi killed $esi def $rsi
62; X64-NEXT:    leal (%rsi,%rdi), %eax
63; X64-NEXT:    # kill: def $al killed $al killed $eax
64; X64-NEXT:    retq
65;
66; X86-LABEL: test_add_i8:
67; X86:       # %bb.0:
68; X86-NEXT:    movb {{[0-9]+}}(%esp), %al
69; X86-NEXT:    addb {{[0-9]+}}(%esp), %al
70; X86-NEXT:    retl
71  %ret = add i8 %arg1, %arg2
72  ret i8 %ret
73}
74
75define i32 @test_add_i1(i32 %arg1, i32 %arg2) {
76; X64-LABEL: test_add_i1:
77; X64:       # %bb.0:
78; X64-NEXT:    cmpl %esi, %edi
79; X64-NEXT:    sete %al
80; X64-NEXT:    addb %al, %al
81; X64-NEXT:    movzbl %al, %eax
82; X64-NEXT:    andl $1, %eax
83; X64-NEXT:    retq
84;
85; X86-LABEL: test_add_i1:
86; X86:       # %bb.0:
87; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
88; X86-NEXT:    cmpl %eax, {{[0-9]+}}(%esp)
89; X86-NEXT:    sete %al
90; X86-NEXT:    addb %al, %al
91; X86-NEXT:    movzbl %al, %eax
92; X86-NEXT:    andl $1, %eax
93; X86-NEXT:    retl
94  %c = icmp eq i32 %arg1, %arg2
95  %x = add i1 %c , %c
96  %ret = zext i1 %x to i32
97  ret i32 %ret
98}
99