1 ; RUN: llc < %s -march=x86 | FileCheck %s -check-prefix=X32
2 ; RUN: llc < %s -march=x86-64 | FileCheck %s -check-prefix=X64
4 ; The immediate can be encoded in a smaller way if the
5 ; instruction is a sub instead of an add.
7 define i32 @test1(i32 inreg %a) nounwind {
10 ; X32: subl $-128, %eax
13 define i64 @test2(i64 inreg %a) nounwind {
14 %b = add i64 %a, 2147483648
16 ; X32: addl $-2147483648, %eax
17 ; X64: subq $-2147483648,
19 define i64 @test3(i64 inreg %a) nounwind {
23 ; X32: addl $128, %eax
27 define i1 @test4(i32 %v1, i32 %v2, i32* %X) nounwind {
29 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %v2)
30 %sum = extractvalue {i32, i1} %t, 0
31 %obit = extractvalue {i32, i1} %t, 1
32 br i1 %obit, label %overflow, label %normal
46 ; X64: addl %esi, %edi
50 define i1 @test5(i32 %v1, i32 %v2, i32* %X) nounwind {
52 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2)
53 %sum = extractvalue {i32, i1} %t, 0
54 %obit = extractvalue {i32, i1} %t, 1
55 br i1 %obit, label %carry, label %normal
69 ; X64: addl %esi, %edi
73 declare {i32, i1} @llvm.sadd.with.overflow.i32(i32, i32)
74 declare {i32, i1} @llvm.uadd.with.overflow.i32(i32, i32)
77 define i64 @test6(i64 %A, i32 %B) nounwind {
78 %tmp12 = zext i32 %B to i64 ; <i64> [#uses=1]
79 %tmp3 = shl i64 %tmp12, 32 ; <i64> [#uses=1]
80 %tmp5 = add i64 %tmp3, %A ; <i64> [#uses=1]
84 ; X32: movl 12(%esp), %edx
85 ; X32-NEXT: addl 8(%esp), %edx
86 ; X32-NEXT: movl 4(%esp), %eax
91 ; X64: leaq (%rsi,%rdi), %rax