Dan Gohman | 13b1ad6 | 2009-09-25 23:58:45 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -march=x86-64 -asm-verbose=false | FileCheck %s |
| 2 | |
| 3 | ; Currently, floating-point selects are lowered to CFG triangles. |
| 4 | ; This means that one side of the select is always unconditionally |
| 5 | ; evaluated, however with MachineSink we can sink the other side so |
| 6 | ; that it's conditionally evaluated. |
| 7 | |
| 8 | ; CHECK: foo: |
| 9 | ; CHECK-NEXT: divsd |
Evan Cheng | 58cb38c | 2009-09-28 05:28:43 +0000 | [diff] [blame] | 10 | ; CHECK: testb $1, %dil |
Dan Gohman | 13b1ad6 | 2009-09-25 23:58:45 +0000 | [diff] [blame] | 11 | ; CHECK-NEXT: jne |
| 12 | |
| 13 | define double @foo(double %x, double %y, i1 %c) nounwind { |
| 14 | %a = fdiv double %x, 3.2 |
| 15 | %b = fdiv double %y, 3.3 |
| 16 | %z = select i1 %c, double %a, double %b |
| 17 | ret double %z |
| 18 | } |
| 19 | |
| 20 | ; Hoist floating-point constant-pool loads out of loops. |
| 21 | |
| 22 | ; CHECK: bar: |
| 23 | ; CHECK: movsd |
| 24 | ; CHECK: align |
| 25 | define void @bar(double* nocapture %p, i64 %n) nounwind { |
| 26 | entry: |
| 27 | %0 = icmp sgt i64 %n, 0 |
| 28 | br i1 %0, label %bb, label %return |
| 29 | |
| 30 | bb: |
| 31 | %i.03 = phi i64 [ 0, %entry ], [ %3, %bb ] |
| 32 | %scevgep = getelementptr double* %p, i64 %i.03 |
| 33 | %1 = load double* %scevgep, align 8 |
| 34 | %2 = fdiv double 3.200000e+00, %1 |
| 35 | store double %2, double* %scevgep, align 8 |
| 36 | %3 = add nsw i64 %i.03, 1 |
| 37 | %exitcond = icmp eq i64 %3, %n |
| 38 | br i1 %exitcond, label %return, label %bb |
| 39 | |
| 40 | return: |
| 41 | ret void |
| 42 | } |