Skip to content
Snippets Groups Projects

gcc vzeroupper

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Henrik Gramner

    gcc (Debian 14.2.0-17) 14.2.0

    gcc -mavx -O1:

    0000000000000000 <copy>:
       0:   c5 fe 6f 06             vmovdqu ymm0,YMMWORD PTR [rsi]
       4:   c5 fe 7f 07             vmovdqu YMMWORD PTR [rdi],ymm0
       8:   c3                      ret
    
    0000000000000009 <zero>:
       9:   c5 f9 ef c0             vpxor  xmm0,xmm0,xmm0
       d:   c5 fe 7f 07             vmovdqu YMMWORD PTR [rdi],ymm0
      11:   c3                      ret

    gcc -mavx -O2:

    0000000000000000 <copy>:
       0:   c5 fe 6f 06             vmovdqu ymm0,YMMWORD PTR [rsi]
       4:   c5 fe 7f 07             vmovdqu YMMWORD PTR [rdi],ymm0
       8:   c5 f8 77                vzeroupper
       b:   c3                      ret
    
    0000000000000010 <zero>:
      10:   c5 f9 ef c0             vpxor  xmm0,xmm0,xmm0
      14:   c5 fe 7f 07             vmovdqu YMMWORD PTR [rdi],ymm0
      18:   c5 f8 77                vzeroupper
      1b:   c3                      ret
    Edited
    test.c 140 B
    #include <string.h>
    
    void copy(void *dst, void *src) {
        memcpy(dst, src, 32);
    }
    
    void zero(void *dst) {
        memset(dst, 0, 32);
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment