Mon P Wang | 95be699 | 2009-01-31 06:50:54 +0000 | [diff] [blame] | 1 | ; RUN: llvm-as -o - %s | llc -march=cellspu -enable-unsafe-fp-math > %t1.s |
Chris Lattner | 994d6cf | 2008-01-18 19:53:43 +0000 | [diff] [blame] | 2 | ; RUN: grep fa %t1.s | count 2 |
| 3 | ; RUN: grep fs %t1.s | count 2 |
| 4 | ; RUN: grep fm %t1.s | count 6 |
| 5 | ; RUN: grep fma %t1.s | count 2 |
| 6 | ; RUN: grep fms %t1.s | count 2 |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 7 | ; RUN: grep fnms %t1.s | count 3 |
| 8 | ; |
| 9 | ; This file includes standard floating point arithmetic instructions |
| 10 | ; NOTE fdiv is tested separately since it is a compound operation |
Scott Michel | 9de5d0d | 2008-01-11 02:53:15 +0000 | [diff] [blame] | 11 | target datalayout = "E-p:32:32:128-f64:64:128-f32:32:128-i64:32:128-i32:32:128-i16:16:128-i8:8:128-i1:8:128-a0:0:128-v128:128:128-s0:128:128" |
| 12 | target triple = "spu" |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 13 | |
| 14 | define float @fp_add(float %arg1, float %arg2) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 15 | %A = fadd float %arg1, %arg2 ; <float> [#uses=1] |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 16 | ret float %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | define <4 x float> @fp_add_vec(<4 x float> %arg1, <4 x float> %arg2) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 20 | %A = fadd <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1] |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 21 | ret <4 x float> %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | define float @fp_sub(float %arg1, float %arg2) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 25 | %A = fsub float %arg1, %arg2 ; <float> [#uses=1] |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 26 | ret float %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | define <4 x float> @fp_sub_vec(<4 x float> %arg1, <4 x float> %arg2) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 30 | %A = fsub <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1] |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 31 | ret <4 x float> %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | define float @fp_mul(float %arg1, float %arg2) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 35 | %A = fmul float %arg1, %arg2 ; <float> [#uses=1] |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 36 | ret float %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | define <4 x float> @fp_mul_vec(<4 x float> %arg1, <4 x float> %arg2) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 40 | %A = fmul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1] |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 41 | ret <4 x float> %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | define float @fp_mul_add(float %arg1, float %arg2, float %arg3) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 45 | %A = fmul float %arg1, %arg2 ; <float> [#uses=1] |
| 46 | %B = fadd float %A, %arg3 ; <float> [#uses=1] |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 47 | ret float %B |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | define <4 x float> @fp_mul_add_vec(<4 x float> %arg1, <4 x float> %arg2, <4 x float> %arg3) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 51 | %A = fmul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1] |
| 52 | %B = fadd <4 x float> %A, %arg3 ; <<4 x float>> [#uses=1] |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 53 | ret <4 x float> %B |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | define float @fp_mul_sub(float %arg1, float %arg2, float %arg3) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 57 | %A = fmul float %arg1, %arg2 ; <float> [#uses=1] |
| 58 | %B = fsub float %A, %arg3 ; <float> [#uses=1] |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 59 | ret float %B |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | define <4 x float> @fp_mul_sub_vec(<4 x float> %arg1, <4 x float> %arg2, <4 x float> %arg3) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 63 | %A = fmul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1] |
| 64 | %B = fsub <4 x float> %A, %arg3 ; <<4 x float>> [#uses=1] |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 65 | ret <4 x float> %B |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | ; Test the straightforward way of getting fnms |
| 69 | ; c - a * b |
| 70 | define float @fp_neg_mul_sub_1(float %arg1, float %arg2, float %arg3) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 71 | %A = fmul float %arg1, %arg2 |
| 72 | %B = fsub float %arg3, %A |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 73 | ret float %B |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | ; Test another way of getting fnms |
| 77 | ; - ( a *b -c ) = c - a * b |
| 78 | define float @fp_neg_mul_sub_2(float %arg1, float %arg2, float %arg3) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 79 | %A = fmul float %arg1, %arg2 |
| 80 | %B = fsub float %A, %arg3 |
| 81 | %C = fsub float -0.0, %B |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 82 | ret float %C |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | define <4 x float> @fp_neg_mul_sub_vec(<4 x float> %arg1, <4 x float> %arg2, <4 x float> %arg3) { |
Dan Gohman | ae3a0be | 2009-06-04 22:49:04 +0000 | [diff] [blame^] | 86 | %A = fmul <4 x float> %arg1, %arg2 |
| 87 | %B = fsub <4 x float> %A, %arg3 |
| 88 | %D = fsub <4 x float> < float -0.0, float -0.0, float -0.0, float -0.0 >, %B |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 89 | ret <4 x float> %D |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 90 | } |