Benjamin Kramer | 77c4ef8 | 2012-05-06 14:25:16 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=x86-64 -mcpu=core2 < %s | FileCheck %s |
Benjamin Kramer | 5995750 | 2012-05-05 12:49:22 +0000 | [diff] [blame] | 2 | |
| 3 | ; cmp with single-use load, should not form cmov. |
| 4 | define 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. |
| 17 | define 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. |
| 27 | define 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. |
| 40 | define 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. |
| 52 | define 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 | } |