Repository navigation
JIT: Investigate fallthrough flow regression from empty block removal #129275
Copy link
Copy link
Open
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Milestone
Description
In the diffs from #129092 there are a few cases where we no longer have fallthrough flow.
Example 1. coreclr_tests System.Math:Max.
G_M48648_IG08 -> G_M48648_IG07
G_M48648_IG02: ;; offset=0x0000
vucomiss xmm0, xmm1
jp SHORT G_M48648_IG03
je SHORT G_M48648_IG08
;; size=8 bbWeight=1 PerfScore 4.00
G_M48648_IG03: ;; offset=0x0008
vucomiss xmm0, xmm0
jp SHORT G_M48648_IG04
vucomiss xmm0, xmm1
jbe SHORT G_M48648_IG07
;; size=12 bbWeight=1 PerfScore 6.00
G_M48648_IG04: ;; offset=0x0014
vmovaps xmm1, xmm0
;; size=4 bbWeight=1 PerfScore 0.25
G_M48648_IG05: ;; offset=0x0018
vmovaps xmm0, xmm1
;; size=4 bbWeight=1 PerfScore 0.25
G_M48648_IG06: ;; offset=0x001C
ret
;; size=1 bbWeight=1 PerfScore 1.00
G_M48648_IG07: ;; offset=0x001D
jmp SHORT G_M48648_IG05
;; size=2 bbWeight=0 PerfScore 0.00
G_M48648_IG08: ;; offset=0x001F
vmovd eax, xmm1
test eax, eax
jl SHORT G_M48648_IG04
jmp SHORT G_M48648_IG07
;; size=10 bbWeight=0 PerfScore 0.00Example 2. benchmarks.run_pgo.windows System.Text.RegularExpressions.RegexNode:get_IsBacktrackingConstruct
G_M48811_IG07 -> G_M48811_IG05
G_M48811_IG02: ;; offset=0x0000
movzx rax, byte ptr [rcx+0x2E]
lea edx, [rax-0x03]
cmp edx, 5
jbe SHORT G_M48811_IG07
cmp eax, 24
je SHORT G_M48811_IG05
add eax, -26
cmp eax, 1
jbe SHORT G_M48811_IG06
;; size=25 bbWeight=1 PerfScore 6.50
G_M48811_IG03: ;; offset=0x0019
xor eax, eax
;; size=2 bbWeight=1 PerfScore 0.25
G_M48811_IG04: ;; offset=0x001B
ret
;; size=1 bbWeight=1 PerfScore 1.00
G_M48811_IG05: ;; offset=0x001C
mov eax, 1
jmp SHORT G_M48811_IG04
;; size=7 bbWeight=0 PerfScore 0.00
G_M48811_IG06: ;; offset=0x0023
mov eax, dword ptr [rcx+0x20]
cmp eax, dword ptr [rcx+0x24]
je SHORT G_M48811_IG03
jmp SHORT G_M48811_IG05
;; size=10 bbWeight=0 PerfScore 0.00
G_M48811_IG07: ;; offset=0x002D
mov eax, dword ptr [rcx+0x20]
cmp eax, dword ptr [rcx+0x24]
je SHORT G_M48811_IG03
jmp SHORT G_M48811_IG05
;; size=10 bbWeight=0 PerfScore 0.00Note how these cases are evolving arround bbWeight=0.0.
The original PR just removed empty blocks. I don't see why the new codegen would be any worse.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Activity
dotnet-policy-service commentedon Jun 11, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
MihuBot commentedon Jun 11, 2026
I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):
fgRemoveBlockdoes not maintain edge weights #96614[-]JIT: Investigate regressions from empty block removal[/-][+]JIT: Investigate fallthrough flow regression from empty block removal[/+]BoyBaykiller commentedon Jun 12, 2026
So the reason for the diffs is quite simple.
Layout opts intentionally don't waste time on
bbWeight=0.0blocks:runtime/src/coreclr/jit/fgopt.cpp
Lines 4217 to 4228 in 2f38215
I wonder if we can at least do something to avoid spurious diffs. Such as ordering all
bbWeight=0.0blocks bybbNum.Also I'm gonna try lift that restriction just to see diffs/tp impact. (@AndyAyersMS)