comparison run/a/asm_pfrcpit1_01_B.d @ 1288:61d7e32e70a8

partial inline asm review
author thomask
date Wed, 27 Dec 2006 11:59:19 +0000
parents 03c97933de98
children 7a397590d6e0
comparison
equal deleted inserted replaced
1287:8cd17283ece1 1288:61d7e32e70a8
15 15
16 int main(){ 16 int main(){
17 haveMMX!()(); 17 haveMMX!()();
18 have3DNow!()(); 18 have3DNow!()();
19 19
20 const float[2] A = [2.0f, -0.5f]; 20 float* a = (new float[2]).ptr;
21 float[2] c; 21 a[0] = 2.0f;
22 a[1] = -0.5f;
22 23
23 asm{ 24 float* c = (new float[2]).ptr;
24 movq MM1, A; 25
25 pfrcp MM0, MM1; 26 static if(size_t.sizeof == 4){
26 pfrcpit1 MM0, MM1; 27 asm{
27 movq c, MM0; 28 mov EAX, a;
28 emms; 29 movq MM1, [EAX];
30 pfrcp MM0, MM1;
31 pfrcpit1 MM0, MM1;
32 mov EAX, c;
33 movq [EAX], MM0;
34 emms;
35 }
36 }else static if(size_t.sizeof == 8){
37 asm{
38 mov RAX, a;
39 movq MM1, [RAX];
40 pfrcp MM0, MM1;
41 pfrcpit1 MM0, MM1;
42 mov RAX, c;
43 movq [RAX], MM0;
44 emms;
45 }
46 }else{
47 static assert(0, "unhandled pointer size");
29 } 48 }
30 49
31 c[0] -= 1.007812f; 50 c[0] -= 1.007812f;
32 if(c[0] < 0.0f){ 51 if(c[0] < 0.0f){
33 c[0] = -c[0]; 52 c[0] = -c[0];
34 } 53 }
35 if(c[0] > float.epsilon * (1 << 11)){ 54 if(c[0] > float.epsilon * (1 << 8)){
36 assert(0); 55 assert(0);
37 } 56 }
38 57
39 c[1] += 1.007812f; 58 c[1] -= 1.007812;
40 if(c[0] < 0.0f){ 59 if(c[1] < 0.0f){
41 c[0] = -c[0]; 60 c[1] = -c[1];
42 } 61 }
43 if(c[0] > float.epsilon * (1 << 11)){ 62 if(c[1] > float.epsilon * (1 << 8)){
44 assert(0); 63 assert(0);
45 } 64 }
46 65
47 return 0; 66 return 0;
48 } 67 }