dotnet / dotnet/runtime

JIT: Investigate fallthrough flow regression from empty block removal

Open
#129,275 3 comments 0 reactions 1 assignee Claimed by @BoyBaykiller View on GitHub
area-CodeGen-coreclr help wanted
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

In the [diffs](https://file.kiwi/ecc47709#VQCnpQILfdzWqHInZpFKNw) from https://github.com/dotnet/runtime/pull/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`
```assembly
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.00
```

Example 2. `benchmarks.run_pgo.windows` `System.Text.RegularExpressions.RegexNode:get_IsBacktrackingConstruct`
`G_M48811_IG07` -> `G_M48811_IG05`
```assembly
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.00
```

Note 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.