blob: ef44a3d119b8aa5953629bff04f35ece37b945fa [file] [log] [blame]
Chris Lattnerae37c2a2005-01-02 02:30:04 +00001; The register allocator can commute two-address instructions to avoid
2; insertion of register-register copies.
3
Chris Lattnerf2c7af22005-05-09 05:54:27 +00004; Make sure there are only 3 mov's for each testcase
Evan Chengbbc726d2010-12-14 21:34:53 +00005; RUN: llc < %s -mtriple=i686-pc-linux-gnu | FileCheck %s -check-prefix=LINUX
6; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s -check-prefix=DARWIN
Chris Lattnerae37c2a2005-01-02 02:30:04 +00007
Chris Lattner837451b2005-07-20 03:56:48 +00008
Tanya Lattner33eefff2008-02-21 07:42:26 +00009@G = external global i32 ; <i32*> [#uses=2]
Chris Lattner837451b2005-07-20 03:56:48 +000010
Tanya Lattner33eefff2008-02-21 07:42:26 +000011declare void @ext(i32)
Chris Lattnerae37c2a2005-01-02 02:30:04 +000012
Evan Chengbbc726d2010-12-14 21:34:53 +000013define i32 @t1(i32 %X, i32 %Y) nounwind {
14; LINUX: t1:
15; LINUX: movl 4(%esp), %eax
16; LINUX: movl 8(%esp), %ecx
17; LINUX: addl %eax, %ecx
18; LINUX: movl %ecx, G
Tanya Lattner33eefff2008-02-21 07:42:26 +000019 %Z = add i32 %X, %Y ; <i32> [#uses=1]
20 store i32 %Z, i32* @G
21 ret i32 %X
Chris Lattnerae37c2a2005-01-02 02:30:04 +000022}
23
Evan Chengbbc726d2010-12-14 21:34:53 +000024define i32 @t2(i32 %X, i32 %Y) nounwind {
25; LINUX: t2:
26; LINUX: movl 4(%esp), %eax
27; LINUX: movl 8(%esp), %ecx
28; LINUX: xorl %eax, %ecx
29; LINUX: movl %ecx, G
Tanya Lattner33eefff2008-02-21 07:42:26 +000030 %Z = xor i32 %X, %Y ; <i32> [#uses=1]
31 store i32 %Z, i32* @G
32 ret i32 %X
Chris Lattnerae37c2a2005-01-02 02:30:04 +000033}
Tanya Lattner33eefff2008-02-21 07:42:26 +000034
Evan Chengbbc726d2010-12-14 21:34:53 +000035; rdar://8762995
36%0 = type { i64, i32 }
37
38define %0 @t3(i32 %lb, i8 zeroext %has_lb, i8 zeroext %lb_inclusive, i32 %ub, i8 zeroext %has_ub, i8 zeroext %ub_inclusive) nounwind {
39entry:
40; DARWIN: t3:
Eric Christopher7c2cdb12011-03-08 02:42:25 +000041; DARWIN: shll $16
Evan Chengbbc726d2010-12-14 21:34:53 +000042; DARWIN: shlq $32, %rcx
43; DARWIN-NOT: leaq
44; DARWIN: orq %rcx, %rax
Evan Chengbbc726d2010-12-14 21:34:53 +000045 %tmp21 = zext i32 %lb to i64
46 %tmp23 = zext i32 %ub to i64
47 %tmp24 = shl i64 %tmp23, 32
48 %ins26 = or i64 %tmp24, %tmp21
49 %tmp28 = zext i8 %has_lb to i32
50 %tmp33 = zext i8 %has_ub to i32
51 %tmp34 = shl i32 %tmp33, 8
52 %tmp38 = zext i8 %lb_inclusive to i32
53 %tmp39 = shl i32 %tmp38, 16
54 %tmp43 = zext i8 %ub_inclusive to i32
55 %tmp44 = shl i32 %tmp43, 24
56 %ins31 = or i32 %tmp39, %tmp28
57 %ins36 = or i32 %ins31, %tmp34
58 %ins46 = or i32 %ins36, %tmp44
59 %tmp16 = insertvalue %0 undef, i64 %ins26, 0
60 %tmp19 = insertvalue %0 %tmp16, i32 %ins46, 1
61 ret %0 %tmp19
62}