Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame^] | 1 | ; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s |
| 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 && |
| 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 |
| 11 | |
| 12 | define float @fp_add(float %arg1, float %arg2) { |
| 13 | %A = add float %arg1, %arg2 ; <float> [#uses=1] |
| 14 | ret float %A |
| 15 | } |
| 16 | |
| 17 | define <4 x float> @fp_add_vec(<4 x float> %arg1, <4 x float> %arg2) { |
| 18 | %A = add <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1] |
| 19 | ret <4 x float> %A |
| 20 | } |
| 21 | |
| 22 | define float @fp_sub(float %arg1, float %arg2) { |
| 23 | %A = sub float %arg1, %arg2 ; <float> [#uses=1] |
| 24 | ret float %A |
| 25 | } |
| 26 | |
| 27 | define <4 x float> @fp_sub_vec(<4 x float> %arg1, <4 x float> %arg2) { |
| 28 | %A = sub <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1] |
| 29 | ret <4 x float> %A |
| 30 | } |
| 31 | |
| 32 | define float @fp_mul(float %arg1, float %arg2) { |
| 33 | %A = mul float %arg1, %arg2 ; <float> [#uses=1] |
| 34 | ret float %A |
| 35 | } |
| 36 | |
| 37 | define <4 x float> @fp_mul_vec(<4 x float> %arg1, <4 x float> %arg2) { |
| 38 | %A = mul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1] |
| 39 | ret <4 x float> %A |
| 40 | } |
| 41 | |
| 42 | define float @fp_mul_add(float %arg1, float %arg2, float %arg3) { |
| 43 | %A = mul float %arg1, %arg2 ; <float> [#uses=1] |
| 44 | %B = add float %A, %arg3 ; <float> [#uses=1] |
| 45 | ret float %B |
| 46 | } |
| 47 | |
| 48 | define <4 x float> @fp_mul_add_vec(<4 x float> %arg1, <4 x float> %arg2, <4 x float> %arg3) { |
| 49 | %A = mul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1] |
| 50 | %B = add <4 x float> %A, %arg3 ; <<4 x float>> [#uses=1] |
| 51 | ret <4 x float> %B |
| 52 | } |
| 53 | |
| 54 | define float @fp_mul_sub(float %arg1, float %arg2, float %arg3) { |
| 55 | %A = mul float %arg1, %arg2 ; <float> [#uses=1] |
| 56 | %B = sub float %A, %arg3 ; <float> [#uses=1] |
| 57 | ret float %B |
| 58 | } |
| 59 | |
| 60 | define <4 x float> @fp_mul_sub_vec(<4 x float> %arg1, <4 x float> %arg2, <4 x float> %arg3) { |
| 61 | %A = mul <4 x float> %arg1, %arg2 ; <<4 x float>> [#uses=1] |
| 62 | %B = sub <4 x float> %A, %arg3 ; <<4 x float>> [#uses=1] |
| 63 | ret <4 x float> %B |
| 64 | } |
| 65 | |
| 66 | ; Test the straightforward way of getting fnms |
| 67 | ; c - a * b |
| 68 | define float @fp_neg_mul_sub_1(float %arg1, float %arg2, float %arg3) { |
| 69 | %A = mul float %arg1, %arg2 |
| 70 | %B = sub float %arg3, %A |
| 71 | ret float %B |
| 72 | } |
| 73 | |
| 74 | ; Test another way of getting fnms |
| 75 | ; - ( a *b -c ) = c - a * b |
| 76 | define float @fp_neg_mul_sub_2(float %arg1, float %arg2, float %arg3) { |
| 77 | %A = mul float %arg1, %arg2 |
| 78 | %B = sub float %A, %arg3 |
| 79 | %C = sub float -0.0, %B |
| 80 | ret float %C |
| 81 | } |
| 82 | |
| 83 | define <4 x float> @fp_neg_mul_sub_vec(<4 x float> %arg1, <4 x float> %arg2, <4 x float> %arg3) { |
| 84 | %A = mul <4 x float> %arg1, %arg2 |
| 85 | %B = sub <4 x float> %A, %arg3 |
| 86 | %D = sub <4 x float> < float -0.0, float -0.0, float -0.0, float -0.0 >, %B |
| 87 | ret <4 x float> %D |
| 88 | } |