Skip to content

Excessive nop instructions when branching and after calls in optimized release builds #83081

@Draugr-official

Description

@Draugr-official

After looking through the CIL of some test applications I build, I noticed that Roslyn produces some extra nop instructions instead of just directly branching to the given code block.

I used the latest version of Visual Studio 2026 Community alongside .NET 10.0.201.

Image

The code used to produce this CIL:

namespace TEST_CS_NET_10
{
    internal class Program
    {
        static void Main(string[] args)
        {
            for(int i = 0; i <= 10; i++)
            {
                Console.WriteLine(i);
            }
        }
    }
}

Is this just lazy compiler design, intentional or overseen? I dont see the debug use for these instructions, especially since its a release build.

Would this cause excess file size / performance issues in large, intense projects or has this been ignored simply because its too trivial?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions