Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7398393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:51:51+00:00 2026-05-29T03:51:51+00:00

After executing gcc -m64 -O test.c -save-temps , I noticed that: mov %edi, %edi

  • 0

After executing gcc -m64 -O test.c -save-temps, I noticed that:
mov %edi, %edi
appears in the generated assembly. Does this instruction even do anything? It moves %edi into itself, effectively accomplishing nothing.

All optimization levels produce this assembly, though in some cases it is placed differently.

Please let me know if you need me to provide further context. As of posting this question, I don’t feel that further context is necessary, but I could be incorrect.

Code of procedure:

 subl    $400, %edi
 cmpl    $20, %edi
 ja      .L4
 mov     %edi, %edi
 jmp     *.L11(,%rdi,8)

This is referencing a jump table for a switch statement.

C Source:

int main()
{

}

int thing(int x)
{

   switch(x)
   {
        case 400:
        return  1;
        break;
        case 404:
        return  2;
        break;
        case 408:
        return  3;
        break;
        case 412:
        return  4;
        break;
        case 416:
        return  5;
        break;
        case 420:
        return  6;
        break;
   }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:51:52+00:00Added an answer on May 29, 2026 at 3:51 am

    In 64-bit mode, the mov instruction when used on 32-bit registers will zero the upper 32-bits of the destination register.

    So:

    mov %edi, %edi
    

    clears the top 32-bits of rdi.

    http://en.wikipedia.org/wiki/MOV_%28x86_instruction%29 (scroll all the way down)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've noticed that my code errors out on sqlWrite.ExecuteNonQuery(); after executing 200 Insert queries
I've noticed that created resouce attributes are all blank after executing build_resource at Devise::RegistrationsController
I was confused that a thread is automatically stops after executing the return statement
I'm reading The Art of Assembly: The MMX Instruction Set , After executing some
I have a WCF service with many methods. I would like that after executing
After logged in successfully, Yii does not executing any page. Showing an error: Error
In UDP client after executing: socket.SendTo(data, SendIP); Why does socket.LocalEndPoint change?
I am writting like that in asp.net2.0 .cs file , after executing code disply
I have a weird condition that only appears on gcc -O0 -g output, not
I'm wondering what would be the correct approach after executing a command that allocates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.