SSE指令优化的简单demo

网上抄的

https://blog.csdn.net/mydear_11000/article/details/50856690

  自己记录一下防忘。

      

  1. #include <intrin.h>  
  2.   
  3. int main(int argc, char* argv[])  
  4. {  
  5.     float op1[4] = {1.0, 2.0, 3.0, 4.0};  
  6.     float op2[4] = {1.0, 2.0, 3.0, 4.0};  
  7.     float result[4];  
  8.   
  9.     __m128  a;  
  10.     __m128  b;  
  11.     __m128  c;  
  12.   
  13.     // Load  
  14.     a = _mm_loadu_ps(op1);  
  15.     b = _mm_loadu_ps(op2);  
  16.   
  17.     // Calculate  
  18.     c = _mm_add_ps(a, b);   // c = a + b  
  19.   
  20.     // Store  
  21.     _mm_storeu_ps(result, c);  
  22.   
  23.     /*      // Using the __m128 union to get the result. 
  24.     printf("0: %lf\n", c.m128_f32[0]); 
  25.     printf("1: %lf\n", c.m128_f32[1]); 
  26.     printf("2: %lf\n", c.m128_f32[2]); 
  27.     printf("3: %lf\n", c.m128_f32[3]); 
  28.     */  
  29.     printf("0: %lf\n", result[0]);  
  30.     printf("1: %lf\n", result[1]);  
  31.     printf("2: %lf\n", result[2]);  
  32.     printf("3: %lf\n", result[3]);  
  33.   
  34.     return 0;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值