如何验证我的代码是否已矢量化?

发布于 2024-12-01 20:52:42 字数 1947 浏览 1 评论 0原文

I am using Automatic Vectorization of compiler to generate the vectorized Code.
For. e.g.  
    for (i = 0; i < 20; i++)  
    {  
        A[i] = i;  
    }  
    for (i = 0; i < 20; i++)  
    {  
        A[i] = A[i] + 5;  
    }

For the above code I am getting assembly code as below ? Is it vectorized or not ?
-------------------------------------------------------------------  
8048380:    55                      push   %ebp  
 8048381:   89 e5                   mov    %esp,%ebp  
 8048383:   56                      push   %esi  
 8048384:   83 ec 64                sub    $0x64,%esp  
 8048387:   c7 45 ac 05 00 00 00    movl   $0x5,-0x54(%ebp)  
 804838e:   c7 45 b0 06 00 00 00    movl   $0x6,-0x50(%ebp)  
 8048395:   c7 45 b4 07 00 00 00    movl   $0x7,-0x4c(%ebp)  
 804839c:   c7 45 b8 08 00 00 00    movl   $0x8,-0x48(%ebp)  
 80483a3:   c7 45 bc 09 00 00 00    movl   $0x9,-0x44(%ebp)  
 80483aa:   c7 45 c0 0a 00 00 00    movl   $0xa,-0x40(%ebp)  
 80483b1:   c7 45 c4 0b 00 00 00    movl   $0xb,-0x3c(%ebp)  
 80483b8:   c7 45 c8 0c 00 00 00    movl   $0xc,-0x38(%ebp)  
 80483bf:   c7 45 cc 0d 00 00 00    movl   $0xd,-0x34(%ebp)  
 80483c6:   c7 45 d0 0e 00 00 00    movl   $0xe,-0x30(%ebp)  
 80483cd:   c7 45 d4 0f 00 00 00    movl   $0xf,-0x2c(%ebp)  
 80483d4:   c7 45 d8 10 00 00 00    movl   $0x10,-0x28(%ebp)  
 80483db:   c7 45 dc 11 00 00 00    movl   $0x11,-0x24(%ebp)  
 80483e2:   c7 45 e0 12 00 00 00    movl   $0x12,-0x20(%ebp)  
 80483e9:   c7 45 e4 13 00 00 00    movl   $0x13,-0x1c(%ebp)  
 80483f0:   c7 45 e8 14 00 00 00    movl   $0x14,-0x18(%ebp)  
 80483f7:   c7 45 ec 15 00 00 00    movl   $0x15,-0x14(%ebp)  
 80483fe:   c7 45 f0 16 00 00 00    movl   $0x16,-0x10(%ebp)  
 8048405:   c7 45 f4 17 00 00 00    movl   $0x17,-0xc(%ebp)  
 804840c:   c7 45 f8 18 00 00 00    movl   $0x18,-0x8(%ebp)  
-----------------------------------------------------------------------  
I am using Automatic Vectorization of compiler to generate the vectorized Code.
For. e.g.  
    for (i = 0; i < 20; i++)  
    {  
        A[i] = i;  
    }  
    for (i = 0; i < 20; i++)  
    {  
        A[i] = A[i] + 5;  
    }

For the above code I am getting assembly code as below ? Is it vectorized or not ?
-------------------------------------------------------------------  
8048380:    55                      push   %ebp  
 8048381:   89 e5                   mov    %esp,%ebp  
 8048383:   56                      push   %esi  
 8048384:   83 ec 64                sub    $0x64,%esp  
 8048387:   c7 45 ac 05 00 00 00    movl   $0x5,-0x54(%ebp)  
 804838e:   c7 45 b0 06 00 00 00    movl   $0x6,-0x50(%ebp)  
 8048395:   c7 45 b4 07 00 00 00    movl   $0x7,-0x4c(%ebp)  
 804839c:   c7 45 b8 08 00 00 00    movl   $0x8,-0x48(%ebp)  
 80483a3:   c7 45 bc 09 00 00 00    movl   $0x9,-0x44(%ebp)  
 80483aa:   c7 45 c0 0a 00 00 00    movl   $0xa,-0x40(%ebp)  
 80483b1:   c7 45 c4 0b 00 00 00    movl   $0xb,-0x3c(%ebp)  
 80483b8:   c7 45 c8 0c 00 00 00    movl   $0xc,-0x38(%ebp)  
 80483bf:   c7 45 cc 0d 00 00 00    movl   $0xd,-0x34(%ebp)  
 80483c6:   c7 45 d0 0e 00 00 00    movl   $0xe,-0x30(%ebp)  
 80483cd:   c7 45 d4 0f 00 00 00    movl   $0xf,-0x2c(%ebp)  
 80483d4:   c7 45 d8 10 00 00 00    movl   $0x10,-0x28(%ebp)  
 80483db:   c7 45 dc 11 00 00 00    movl   $0x11,-0x24(%ebp)  
 80483e2:   c7 45 e0 12 00 00 00    movl   $0x12,-0x20(%ebp)  
 80483e9:   c7 45 e4 13 00 00 00    movl   $0x13,-0x1c(%ebp)  
 80483f0:   c7 45 e8 14 00 00 00    movl   $0x14,-0x18(%ebp)  
 80483f7:   c7 45 ec 15 00 00 00    movl   $0x15,-0x14(%ebp)  
 80483fe:   c7 45 f0 16 00 00 00    movl   $0x16,-0x10(%ebp)  
 8048405:   c7 45 f4 17 00 00 00    movl   $0x17,-0xc(%ebp)  
 804840c:   c7 45 f8 18 00 00 00    movl   $0x18,-0x8(%ebp)  
-----------------------------------------------------------------------  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是一片海 2024-12-08 20:52:42

它不是矢量化的。

但是它会展开,并且您的第一个循环将被删除。

It is not vectorized.

It is however unrolled, and your first loop is removed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文