blob: 780746ab1ae44f30ae61c8146c1ef229dca5b04e [file] [log] [blame]
Benjamin Kramer77c4ef82012-05-06 14:25:16 +00001; RUN: llc -march=x86-64 -mcpu=core2 < %s | FileCheck %s
Benjamin Kramer59957502012-05-05 12:49:22 +00002
3; cmp with single-use load, should not form cmov.
4define i32 @test1(double %a, double* nocapture %b, i32 %x, i32 %y) {
5 %load = load double* %b, align 8
6 %cmp = fcmp olt double %load, %a
7 %cond = select i1 %cmp, i32 %x, i32 %y
8 ret i32 %cond
9; CHECK: test1:
10; CHECK: ucomisd
11; CHECK-NOT: cmov
12; CHECK: j
13; CHECK-NOT: cmov
14}
15
16; Sanity check: no load.
17define i32 @test2(double %a, double %b, i32 %x, i32 %y) {
18 %cmp = fcmp ogt double %a, %b
19 %cond = select i1 %cmp, i32 %x, i32 %y
20 ret i32 %cond
21; CHECK: test2:
22; CHECK: ucomisd
23; CHECK: cmov
24}
25
26; Multiple uses of %a, should not form cmov.
27define i32 @test3(i32 %a, i32* nocapture %b, i32 %x) {
28 %load = load i32* %b, align 4
29 %cmp = icmp ult i32 %load, %a
30 %cond = select i1 %cmp, i32 %a, i32 %x
31 ret i32 %cond
32; CHECK: test3:
33; CHECK: cmpl
34; CHECK-NOT: cmov
35; CHECK: j
36; CHECK-NOT: cmov
37}
38
39; Multiple uses of the load.
40define i32 @test4(i32 %a, i32* nocapture %b, i32 %x, i32 %y) {
41 %load = load i32* %b, align 4
42 %cmp = icmp ult i32 %load, %a
43 %cond = select i1 %cmp, i32 %x, i32 %y
44 %add = add i32 %cond, %load
45 ret i32 %add
46; CHECK: test4:
47; CHECK: cmpl
48; CHECK: cmov
49}
50
51; Multiple uses of the cmp.
52define i32 @test5(i32 %a, i32* nocapture %b, i32 %x, i32 %y) {
53 %load = load i32* %b, align 4
54 %cmp = icmp ult i32 %load, %a
55 %cmp1 = icmp ugt i32 %load, %a
56 %cond = select i1 %cmp1, i32 %a, i32 %y
57 %cond5 = select i1 %cmp, i32 %cond, i32 %x
58 ret i32 %cond5
59; CHECK: test5:
60; CHECK: cmpl
61; CHECK: cmov
62; CHECK: cmov
63}