Skip to content

JIT: SSA-based TryGetRange fails on constant #130206

Closed

Description

@BoyBaykiller

I expect the if (i >= 0) branch to be removed, but it isn't.
Interestingly if I swap the upper bound (100) with a variable (bound) it does.
No godbolt link cause it's outdated (compiler-explorer/dotnet-builder#29)

static void Test(int bound)
{
    for (int i = 0; i < 100; i++)
    {
        if (i >= 0)
        {
            Console.WriteLine("Hi");
        }
    }
}
G_M38621_IG01:  ;; offset=0x0000
       push     rsi
       push     rbx
       sub      rsp, 40
						;; size=6 bbWeight=1 PerfScore 2.25
G_M38621_IG02:  ;; offset=0x0006
       xor      ebx, ebx
       mov      rsi, 0x232D5365040      ; 'Hi'
       jmp      SHORT G_M38621_IG05
       align    [0 bytes for IG03]
						;; size=14 bbWeight=1 PerfScore 2.50
G_M38621_IG03:  ;; offset=0x0014
       inc      ebx
						;; size=2 bbWeight=16 PerfScore 4.00
G_M38621_IG04:  ;; offset=0x0016
       test     ebx, ebx
       jl       SHORT G_M38621_IG03
						;; size=4 bbWeight=32 PerfScore 40.00
G_M38621_IG05:  ;; offset=0x001A
       mov      rcx, rsi
       call     [System.Console:WriteLine(System.String)]
       inc      ebx
       cmp      ebx, 100
       jl       SHORT G_M38621_IG04
						;; size=16 bbWeight=8 PerfScore 38.00
G_M38621_IG06:  ;; offset=0x002A
       add      rsp, 40
       pop      rbx
       pop      rsi
       ret      
						;; size=7 bbWeight=1 PerfScore 2.25

Activity

  1. added
    untriaged
    on Jul 4, 2026
  2. added
    area-CodeGen-coreclr
    on Jul 4, 2026
  3. dotnet-policy-service commented on Jul 4, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
    See info in area-owners.md if you want to be subscribed.

  4. self-assigned this
    on Jul 4, 2026
  5. added this to the 11.0.0 milestone on Jul 4, 2026
  6. removed
    untriaged
    on Jul 4, 2026
  7. locked and limited conversation to collaborators on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions