5a0bf73efce93514bb575417ff7ac7ca4bf14ee4
[oota-llvm.git] / test / CodeGen / X86 / handle-move.ll
1 ; RUN: llc -march=x86-64 -mcpu=core2 -fast-isel -enable-misched -misched=shuffle -misched-bottomup -verify-machineinstrs < %s
2 ; RUN: llc -march=x86-64 -mcpu=core2 -fast-isel -enable-misched -misched=shuffle -misched-topdown -verify-machineinstrs < %s
3 ;
4 ; Test the LiveIntervals::handleMove() function.
5 ;
6 ; Moving the DIV32r instruction exercises the regunit update code because
7 ; %EDX has a live range into the function and is used by the DIV32r.
8 ;
9 ; Here sinking a kill + dead def:
10 ; 144B -> 180B: DIV32r %vreg4, %EAX<imp-def>, %EDX<imp-def,dead>, %EFLAGS<imp-def,dead>, %EAX<imp-use,kill>, %EDX<imp-use>
11 ;       %vreg4: [48r,144r:0)  0@48r
12 ;         -->   [48r,180r:0)  0@48r
13 ;       DH:     [0B,16r:0)[128r,144r:2)[144r,144d:1)  0@0B-phi 1@144r 2@128r
14 ;         -->   [0B,16r:0)[128r,180r:2)[180r,180d:1)  0@0B-phi 1@180r 2@128r
15 ;       DL:     [0B,16r:0)[128r,144r:2)[144r,144d:1)  0@0B-phi 1@144r 2@128r
16 ;         -->   [0B,16r:0)[128r,180r:2)[180r,180d:1)  0@0B-phi 1@180r 2@128r
17 ;
18 define i32 @f1(i32 %a, i32 %b, i32 %c, i32 %d) nounwind uwtable readnone ssp {
19 entry:
20   %y = add i32 %c, 1
21   %x = udiv i32 %b, %a
22   %add = add nsw i32 %y, %x
23   ret i32 %add
24 }
25
26 ; Same as above, but moving a kill + live def:
27 ; 144B -> 180B: DIV32r %vreg4, %EAX<imp-def,dead>, %EDX<imp-def>, %EFLAGS<imp-def,dead>, %EAX<imp-use,kill>, %EDX<imp-use>
28 ;       %vreg4: [48r,144r:0)  0@48r
29 ;         -->   [48r,180r:0)  0@48r
30 ;       DH:     [0B,16r:0)[128r,144r:2)[144r,184r:1)  0@0B-phi 1@144r 2@128r
31 ;         -->   [0B,16r:0)[128r,180r:2)[180r,184r:1)  0@0B-phi 1@180r 2@128r
32 ;       DL:     [0B,16r:0)[128r,144r:2)[144r,184r:1)  0@0B-phi 1@144r 2@128r
33 ;         -->   [0B,16r:0)[128r,180r:2)[180r,184r:1)  0@0B-phi 1@180r 2@128r
34 ;
35 define i32 @f2(i32 %a, i32 %b, i32 %c, i32 %d) nounwind uwtable readnone ssp {
36 entry:
37   %y = sub i32 %c, %d
38   %x = urem i32 %b, %a
39   %add = add nsw i32 %x, %y
40   ret i32 %add
41 }
42
43 ; Moving a use below the existing kill (%vreg5):
44 ; Moving a tied virtual register def (%vreg11):
45 ;
46 ; 96B -> 120B: %vreg11<def,tied1> = SUB32rr %vreg11<tied0>, %vreg5
47 ;       %vreg11:        [80r,96r:1)[96r,144r:0)  0@96r 1@80r
48 ;            -->        [80r,120r:1)[120r,144r:0)  0@120r 1@80r
49 ;       %vreg5:         [16r,112r:0)  0@16r
50 ;            -->        [16r,120r:0)  0@16r
51 ;
52 define i32 @f3(i32 %a, i32 %b, i32 %c, i32 %d) nounwind uwtable readnone ssp {
53 entry:
54   %y = sub i32 %a, %b
55   %x = add i32 %a, %b
56   %r = mul i32 %x, %y
57   ret i32 %r
58 }
59
60 ; Move EFLAGS dead def across another def:
61 ; handleMove 208B -> 36B: %EDX<def> = MOV32r0 %EFLAGS<imp-def,dead>
62 ;    EFLAGS:    [20r,20d:4)[160r,160d:3)[208r,208d:0)[224r,224d:1)[272r,272d:2)[304r,304d:5)  0@208r 1@224r 2@272r 3@160r 4@20r 5@304r
63 ;         -->   [20r,20d:4)[36r,36d:0)[160r,160d:3)[224r,224d:1)[272r,272d:2)[304r,304d:5)  0@36r 1@224r 2@272r 3@160r 4@20r 5@304r
64 ;
65 define i32 @f4(i32 %a, i32 %b, i32 %c, i32 %d) nounwind uwtable readnone ssp {
66 entry:
67   %x = sub i32 %a, %b
68   %y = sub i32 %b, %c
69   %z = sub i32 %c, %d
70   %r1 = udiv i32 %x, %y
71   %r2 = mul i32 %z, %r1
72   ret i32 %r2
73 }