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: |
Dan Gohman | 83cefbc | 2009-09-28 20:48:39 +0000 | [diff] [blame] | 9 | ; CHECK: divsd |
Evan Cheng | 6e2f5a4 | 2009-10-18 19:57:27 +0000 | [diff] [blame] | 10 | ; CHECK-NEXT: testb $1, %dil |
| 11 | ; CHECK-NEXT: jne |
| 12 | ; CHECK-NEXT: divsd |
Dan Gohman | 13b1ad6 | 2009-09-25 23:58:45 +0000 | [diff] [blame] | 13 | |
| 14 | define double @foo(double %x, double %y, i1 %c) nounwind { |
| 15 | %a = fdiv double %x, 3.2 |
| 16 | %b = fdiv double %y, 3.3 |
| 17 | %z = select i1 %c, double %a, double %b |
| 18 | ret double %z |
| 19 | } |
| 20 | |
| 21 | ; Hoist floating-point constant-pool loads out of loops. |
| 22 | |
| 23 | ; CHECK: bar: |
| 24 | ; CHECK: movsd |
| 25 | ; CHECK: align |
| 26 | define void @bar(double* nocapture %p, i64 %n) nounwind { |
| 27 | entry: |
| 28 | %0 = icmp sgt i64 %n, 0 |
| 29 | br i1 %0, label %bb, label %return |
| 30 | |
| 31 | bb: |
| 32 | %i.03 = phi i64 [ 0, %entry ], [ %3, %bb ] |
| 33 | %scevgep = getelementptr double* %p, i64 %i.03 |
| 34 | %1 = load double* %scevgep, align 8 |
| 35 | %2 = fdiv double 3.200000e+00, %1 |
| 36 | store double %2, double* %scevgep, align 8 |
| 37 | %3 = add nsw i64 %i.03, 1 |
| 38 | %exitcond = icmp eq i64 %3, %n |
| 39 | br i1 %exitcond, label %return, label %bb |
| 40 | |
| 41 | return: |
| 42 | ret void |
| 43 | } |
Dan Gohman | 48c10d1 | 2009-10-28 01:13:53 +0000 | [diff] [blame] | 44 | |
| 45 | ; Sink instructions with dead EFLAGS defs. |
| 46 | |
| 47 | ; CHECK: je |
| 48 | ; CHECK-NEXT: orb |
| 49 | |
| 50 | define zeroext i8 @zzz(i8 zeroext %a, i8 zeroext %b) nounwind readnone { |
| 51 | entry: |
| 52 | %tmp = zext i8 %a to i32 ; <i32> [#uses=1] |
| 53 | %tmp2 = icmp eq i8 %a, 0 ; <i1> [#uses=1] |
| 54 | %tmp3 = or i8 %b, -128 ; <i8> [#uses=1] |
| 55 | %tmp4 = and i8 %b, 127 ; <i8> [#uses=1] |
| 56 | %b_addr.0 = select i1 %tmp2, i8 %tmp4, i8 %tmp3 ; <i8> [#uses=1] |
| 57 | ret i8 %b_addr.0 |
| 58 | } |