Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Do not propagate some constants #70378

Merged
merged 11 commits into from
Jun 10, 2022
Merged

JIT: Do not propagate some constants #70378

merged 11 commits into from
Jun 10, 2022

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Jun 7, 2022

Let's see what Diffs think.
Jit always try to propagate single-def constant values but it's not always a good thing, e.g. constant vectors and doubles end up as memory loads and we don't want to propagate them inside loops etc. Same about long integers (e.g. handles) on arm64

This might ruin some Lowering optimizations which expect constant values but I expect to see more benefits than regressions from this.

Closes #70355

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 7, 2022
@ghost ghost assigned EgorBo Jun 7, 2022
@ghost
Copy link

ghost commented Jun 7, 2022

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

Issue Details

Let's see what Diffs think.
Jit always try to propagate single-def constant values but it's not always a good thing, e.g. constant vectors and doubles end up as memory loads and we don't want to propagate them inside loops etc. Same about long integers (e.g. handles) on arm64

This might ruin some Lowering optimizations which expect constant values but I expect to see more benefits than regressions from this.

Closes #70355

Author: EgorBo
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

keepPropagating = true;
}
#elif TARGET_XARCH
// All integer constants are cheap to materialize on xarch
keepPropagating = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right?

Those that fit in 8-bits (generally sign-extended, but sometimes zero-extended) are often (but not always) containable, but if its 2-, 4-, or 8-bytes` then it generally needs a separate instruction and is more expensive.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tannergooding I agree but in this PR I only try to avoid memory loads - there are too many pitfalls this PR can't take into account like register-pressure, cached constants which live across calls on ABIs without callee-saved regs, etc - it's just a quick heuristic at this point

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth logging an issue for someone to experiment here a bit.

I'd expect that most cases of explicit mov reg, imm are better handled by hoisting as it impacts the size of the loop and doesn't allow optimizations in many scenarios.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, I am actually going to spend some time on it after this PR because it's even more important for ARM where it might ends up with 4 mov per single constant

@EgorBo
Copy link
Member Author

EgorBo commented Jun 8, 2022

PerfScore diffs
Time Elapsed 00:00:13.38
BUILDTEST: Test build succeeded.  Finished at  0:22:25.36
BUILDTEST: Test binaries are available at C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked
[00:22:25] ================ Logging to C:\prj\runtime\artifacts\spmi\superpmi.38.log
[00:22:25] Using JIT/EE Version from jiteeversionguid.h: f2a217c4-2a69-4308-99ce-8292c6763776
[00:22:25] Baseline hash: deb4044f6f96a88ec10f4cc6548628e16c3d9215
[00:22:25] Using baseline C:\prj\runtime\artifacts\spmi\basejit\0971e5e22794fc7d7d0744376be2f452e26159ad.windows.x64.Checked\clrjit.dll
[00:22:25] Using coredistools found at C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\coredistools.dll
[00:22:25] Found download cache directory "C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64" and --force_download not set; skipping download
[00:22:25] SuperPMI ASM diffs
[00:22:25] Base JIT Path: C:\prj\runtime\artifacts\spmi\basejit\0971e5e22794fc7d7d0744376be2f452e26159ad.windows.x64.Checked\clrjit.dll
[00:22:25] Diff JIT Path: C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\clrjit.dll
[00:22:25] Using MCH files:
[00:22:25]   C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\aspnet.run.windows.x64.checked.mch
[00:22:25]   C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\benchmarks.run.windows.x64.checked.mch
[00:22:25]   C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\coreclr_tests.pmi.windows.x64.checked.mch
[00:22:25]   C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\libraries.crossgen2.windows.x64.checked.mch
[00:22:25]   C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\libraries.pmi.windows.x64.checked.mch
[00:22:25]   C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\libraries_tests.pmi.windows.x64.checked.mch
[00:22:25] Running asm diffs of C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\aspnet.run.windows.x64.checked.mch
[00:22:49] Asm diffs found
[00:22:49] Creating dasm files: C:\prj\runtime\artifacts\spmi\asm.aspnet.run.windows.x64.checked.2\base C:\prj\runtime\artifacts\spmi\asm.aspnet.run.windows.x64.checked.2\diff
[00:22:50] Differences found. To replay SuperPMI use:
[00:22:50]
[00:22:50] set COMPlus_JitDisasm=*
[00:22:50] set COMPlus_JitUnwindDump=*
[00:22:50] set COMPlus_JitEHDump=*
[00:22:50] set COMPlus_NgenDisasm=*
[00:22:50] set COMPlus_NgenUnwindDump=*
[00:22:50] set COMPlus_NgenEHDump=*
[00:22:50] set COMPlus_JitDiffableDasm=1
[00:22:50] set COMPlus_JitEnableNoWayAssert=1
[00:22:50] set COMPlus_JitNoForceFallback=1
[00:22:50] set COMPlus_JitDisasmWithGC=1
[00:22:50] C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\superpmi.exe  -c ### C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\clrjit.dll C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\aspnet.run.windows.x64.checked.mch
[00:22:50]
[00:22:50] Total bytes of base: 22902649
[00:22:50] Total bytes of diff: 22902727
[00:22:50] Total bytes of delta: 78 (0.00% of base)
[00:22:50] Generated asm is located under C:\prj\runtime\artifacts\spmi\asm.aspnet.run.windows.x64.checked.2\base C:\prj\runtime\artifacts\spmi\asm.aspnet.run.windows.x64.checked.2\diff
[00:22:50] Textual differences found in generated asm.
[00:22:50] Invoking: C:\prj\jitutils\bin\jit-analyze.exe --md C:\prj\runtime\artifacts\spmi\asm.aspnet.run.windows.x64.checked.2\summary.md -r --base C:\prj\runtime\artifacts\spmi\asm.aspnet.run.windows.x64.checked.2\base --diff C:\prj\runtime\artifacts\spmi\asm.aspnet.run.windows.x64.checked.2\diff --metrics PerfScore
[00:22:51] Found 15 files with textual diffs.
[00:22:51]
[00:22:51] Summary of Perf Score diffs:
[00:22:51] (Lower is better)
[00:22:51]
[00:22:51] Total PerfScoreUnits of base: 54390.04
[00:22:51] Total PerfScoreUnits of diff: 52914.68000000001
[00:22:51] Total PerfScoreUnits of delta: -1475.36 (-2.71 % of base)
[00:22:51] Total relative delta: -1.14
[00:22:51]     diff is an improvement.
[00:22:51]     relative diff is an improvement.
[00:22:51]
[00:22:51]
[00:22:51] Top file improvements (PerfScoreUnits):
[00:22:51]      -166.72 : 60097.dasm (-9.33% of base)
[00:22:51]      -166.00 : 48003.dasm (-9.31% of base)
[00:22:51]      -139.57 : 67547.dasm (-8.28% of base)
[00:22:51]      -139.17 : 40875.dasm (-8.28% of base)
[00:22:51]      -135.34 : 38649.dasm (-10.03% of base)
[00:22:51]      -125.70 : 55506.dasm (-0.34% of base)
[00:22:51]       -81.23 : 49552.dasm (-9.65% of base)
[00:22:51]       -80.59 : 61331.dasm (-9.59% of base)
[00:22:51]       -73.78 : 67545.dasm (-10.63% of base)
[00:22:51]       -73.60 : 40872.dasm (-10.62% of base)
[00:22:51]       -72.93 : 67543.dasm (-3.08% of base)
[00:22:51]       -72.76 : 40870.dasm (-3.07% of base)
[00:22:51]       -71.86 : 67789.dasm (-9.54% of base)
[00:22:51]       -71.43 : 41218.dasm (-9.50% of base)
[00:22:51]        -4.68 : 55505.dasm (-3.04% of base)
[00:22:51]
[00:22:51] 15 total files with Perf Score differences (15 improved, 0 regressed), 0 unchanged.
[00:22:51]
[00:22:51] Top method improvements (PerfScoreUnits):
[00:22:51]      -166.72 (-9.33% of base) : 60097.dasm - Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:22:51]      -166.00 (-9.31% of base) : 48003.dasm - Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:22:51]      -139.57 (-8.28% of base) : 67547.dasm - Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:22:51]      -139.17 (-8.28% of base) : 40875.dasm - Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:22:51]      -135.34 (-10.03% of base) : 38649.dasm - ASCIIUtility:NarrowUtf16ToAscii_Sse2(long,long,long):long
[00:22:51]      -125.70 (-0.34% of base) : 55506.dasm - Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:22:51]       -81.23 (-9.65% of base) : 49552.dasm - ASCIIUtility:NarrowUtf16ToAscii_Sse2(long,long,long):long
[00:22:51]       -80.59 (-9.59% of base) : 61331.dasm - ASCIIUtility:NarrowUtf16ToAscii_Sse2(long,long,long):long
[00:22:51]       -73.78 (-10.63% of base) : 67545.dasm - ASCIIUtility:GetIndexOfFirstNonAsciiChar_Sse2(long,long):long
[00:22:51]       -73.60 (-10.62% of base) : 40872.dasm - ASCIIUtility:GetIndexOfFirstNonAsciiChar_Sse2(long,long):long
[00:22:51]       -72.93 (-3.08% of base) : 67543.dasm - Utf16Utility:GetPointerToFirstInvalidChar(long,int,byref,byref):long
[00:22:51]       -72.76 (-3.07% of base) : 40870.dasm - Utf16Utility:GetPointerToFirstInvalidChar(long,int,byref,byref):long
[00:22:51]       -71.86 (-9.54% of base) : 67789.dasm - ASCIIUtility:NarrowUtf16ToAscii_Sse2(long,long,long):long
[00:22:51]       -71.43 (-9.50% of base) : 41218.dasm - ASCIIUtility:NarrowUtf16ToAscii_Sse2(long,long,long):long
[00:22:51]        -4.68 (-3.04% of base) : 55505.dasm - ASCIIUtility:GetIndexOfFirstNonAsciiChar_Sse2(long,long):long
[00:22:51]
[00:22:51] Top method improvements (percentages):
[00:22:51]       -73.78 (-10.63% of base) : 67545.dasm - ASCIIUtility:GetIndexOfFirstNonAsciiChar_Sse2(long,long):long
[00:22:51]       -73.60 (-10.62% of base) : 40872.dasm - ASCIIUtility:GetIndexOfFirstNonAsciiChar_Sse2(long,long):long
[00:22:51]      -135.34 (-10.03% of base) : 38649.dasm - ASCIIUtility:NarrowUtf16ToAscii_Sse2(long,long,long):long
[00:22:51]       -81.23 (-9.65% of base) : 49552.dasm - ASCIIUtility:NarrowUtf16ToAscii_Sse2(long,long,long):long
[00:22:51]       -80.59 (-9.59% of base) : 61331.dasm - ASCIIUtility:NarrowUtf16ToAscii_Sse2(long,long,long):long
[00:22:51]       -71.86 (-9.54% of base) : 67789.dasm - ASCIIUtility:NarrowUtf16ToAscii_Sse2(long,long,long):long
[00:22:51]       -71.43 (-9.50% of base) : 41218.dasm - ASCIIUtility:NarrowUtf16ToAscii_Sse2(long,long,long):long
[00:22:51]      -166.72 (-9.33% of base) : 60097.dasm - Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:22:51]      -166.00 (-9.31% of base) : 48003.dasm - Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:22:51]      -139.57 (-8.28% of base) : 67547.dasm - Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:22:51]      -139.17 (-8.28% of base) : 40875.dasm - Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:22:51]       -72.93 (-3.08% of base) : 67543.dasm - Utf16Utility:GetPointerToFirstInvalidChar(long,int,byref,byref):long
[00:22:51]       -72.76 (-3.07% of base) : 40870.dasm - Utf16Utility:GetPointerToFirstInvalidChar(long,int,byref,byref):long
[00:22:51]        -4.68 (-3.04% of base) : 55505.dasm - ASCIIUtility:GetIndexOfFirstNonAsciiChar_Sse2(long,long):long
[00:22:51]      -125.70 (-0.34% of base) : 55506.dasm - Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:22:51]
[00:22:51] 15 total methods with Perf Score differences (15 improved, 0 regressed), 0 unchanged.
[00:22:51]
[00:22:51] --------------------------------------------------------------------------------
[00:22:51] Warning: SuperPMI encountered missing data during the diff. The diff summary printed above may be misleading.
[00:22:51] Missing with base JIT: 35. Missing with diff JIT: 35. Total contexts: 68606.
[00:22:51] Running asm diffs of C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\benchmarks.run.windows.x64.checked.mch
[00:23:05] Asm diffs found
[00:23:05] Creating dasm files: C:\prj\runtime\artifacts\spmi\asm.benchmarks.run.windows.x64.checked.6\base C:\prj\runtime\artifacts\spmi\asm.benchmarks.run.windows.x64.checked.6\diff
[00:23:06] Differences found. To replay SuperPMI use:
[00:23:06]
[00:23:06] set COMPlus_JitDisasm=*
[00:23:06] set COMPlus_JitUnwindDump=*
[00:23:06] set COMPlus_JitEHDump=*
[00:23:06] set COMPlus_NgenDisasm=*
[00:23:06] set COMPlus_NgenUnwindDump=*
[00:23:06] set COMPlus_NgenEHDump=*
[00:23:06] set COMPlus_JitDiffableDasm=1
[00:23:06] set COMPlus_JitEnableNoWayAssert=1
[00:23:06] set COMPlus_JitNoForceFallback=1
[00:23:06] set COMPlus_JitDisasmWithGC=1
[00:23:06] C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\superpmi.exe  -c ### C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\clrjit.dll C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\benchmarks.run.windows.x64.checked.mch
[00:23:06]
[00:23:06] Total bytes of base: 9936834
[00:23:06] Total bytes of diff: 9937837
[00:23:06] Total bytes of delta: 1003 (0.01% of base)
[00:23:06] Generated asm is located under C:\prj\runtime\artifacts\spmi\asm.benchmarks.run.windows.x64.checked.6\base C:\prj\runtime\artifacts\spmi\asm.benchmarks.run.windows.x64.checked.6\diff
[00:23:06] Textual differences found in generated asm.
[00:23:06] Invoking: C:\prj\jitutils\bin\jit-analyze.exe --md C:\prj\runtime\artifacts\spmi\asm.benchmarks.run.windows.x64.checked.6\summary.md -r --base C:\prj\runtime\artifacts\spmi\asm.benchmarks.run.windows.x64.checked.6\base --diff C:\prj\runtime\artifacts\spmi\asm.benchmarks.run.windows.x64.checked.6\diff --metrics PerfScore
[00:23:06] Found 14 files with textual diffs.
[00:23:06]
[00:23:06] Summary of Perf Score diffs:
[00:23:06] (Lower is better)
[00:23:06]
[00:23:06] Total PerfScoreUnits of base: 135173.35
[00:23:06] Total PerfScoreUnits of diff: 133863.36000000002
[00:23:06] Total PerfScoreUnits of delta: -1309.99 (-0.97 % of base)
[00:23:06] Total relative delta: -0.50
[00:23:06]     diff is an improvement.
[00:23:06]     relative diff is an improvement.
[00:23:06]
[00:23:06]
[00:23:06] Top file regressions (PerfScoreUnits):
[00:23:06]         3.20 : 11723.dasm (1.87% of base)
[00:23:06]         1.48 : 57.dasm (0.67% of base)
[00:23:06]
[00:23:06] Top file improvements (PerfScoreUnits):
[00:23:06]      -277.60 : 37038.dasm (-0.97% of base)
[00:23:06]      -275.85 : 15310.dasm (-0.72% of base)
[00:23:06]      -243.50 : 17565.dasm (-4.49% of base)
[00:23:06]      -117.90 : 59.dasm (-0.22% of base)
[00:23:06]      -117.10 : 9555.dasm (-4.25% of base)
[00:23:06]      -116.50 : 9556.dasm (-4.84% of base)
[00:23:06]       -76.37 : 31733.dasm (-9.63% of base)
[00:23:06]       -28.10 : 16921.dasm (-4.98% of base)
[00:23:06]       -20.40 : 15199.dasm (-7.68% of base)
[00:23:06]       -20.40 : 8662.dasm (-7.53% of base)
[00:23:06]       -13.28 : 16469.dasm (-5.33% of base)
[00:23:06]        -7.67 : 31820.dasm (-1.55% of base)
[00:23:06]
[00:23:06] 14 total files with Perf Score differences (12 improved, 2 regressed), 0 unchanged.
[00:23:06]
[00:23:06] Top method regressions (PerfScoreUnits):
[00:23:06]         3.20 ( 1.87% of base) : 11723.dasm - System.HexConverter:EncodeToUtf16_Vector128(System.ReadOnlySpan`1[Byte],System.Span`1[Char],int)
[00:23:06]         1.48 ( 0.67% of base) : 57.dasm - System.Text.ASCIIUtility:GetIndexOfFirstNonAsciiChar_Sse2(long,long):long
[00:23:06]
[00:23:06] Top method improvements (PerfScoreUnits):
[00:23:06]      -277.60 (-0.97% of base) : 37038.dasm - Benchstone.BenchF.LLoops:Main1(int):this
[00:23:06]      -275.85 (-0.72% of base) : 15310.dasm - Benchstone.MDBenchF.MDLLoops:Main1(int):this
[00:23:06]      -243.50 (-4.49% of base) : 17565.dasm - BenchmarksGame.Mandelbrot_2:DoBench(int,System.IO.MemoryStream,bool)
[00:23:06]      -117.90 (-0.22% of base) : 59.dasm - System.Text.Unicode.Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:23:06]      -117.10 (-4.25% of base) : 9555.dasm - FractalPerf.Mandelbrot:Render():double:this
[00:23:06]      -116.50 (-4.84% of base) : 9556.dasm - FractalPerf.Julia:Render():double:this
[00:23:06]       -76.37 (-9.63% of base) : 31733.dasm - System.Buffers.Text.Base64:DecodeFromUtf8(System.ReadOnlySpan`1[Byte],System.Span`1[Byte],byref,byref,bool):int
[00:23:06]       -28.10 (-4.98% of base) : 16921.dasm - System.Buffers.Text.Base64:EncodeToUtf8(System.ReadOnlySpan`1[Byte],System.Span`1[Byte],byref,byref,bool):int
[00:23:06]       -20.40 (-7.68% of base) : 15199.dasm - System.SpanHelpers:Reverse(byref,long)
[00:23:06]       -20.40 (-7.53% of base) : 8662.dasm - System.SpanHelpers:Reverse(byref,long)
[00:23:06]       -13.28 (-5.33% of base) : 16469.dasm - System.SpanHelpers:Reverse(byref,long)
[00:23:06]        -7.67 (-1.55% of base) : 31820.dasm - System.Collections.BitArray:CopyTo(System.Array,int):this
[00:23:06]
[00:23:06] Top method regressions (percentages):
[00:23:06]         3.20 ( 1.87% of base) : 11723.dasm - System.HexConverter:EncodeToUtf16_Vector128(System.ReadOnlySpan`1[Byte],System.Span`1[Char],int)
[00:23:06]         1.48 ( 0.67% of base) : 57.dasm - System.Text.ASCIIUtility:GetIndexOfFirstNonAsciiChar_Sse2(long,long):long
[00:23:06]
[00:23:06] Top method improvements (percentages):
[00:23:06]       -76.37 (-9.63% of base) : 31733.dasm - System.Buffers.Text.Base64:DecodeFromUtf8(System.ReadOnlySpan`1[Byte],System.Span`1[Byte],byref,byref,bool):int
[00:23:06]       -20.40 (-7.68% of base) : 15199.dasm - System.SpanHelpers:Reverse(byref,long)
[00:23:06]       -20.40 (-7.53% of base) : 8662.dasm - System.SpanHelpers:Reverse(byref,long)
[00:23:06]       -13.28 (-5.33% of base) : 16469.dasm - System.SpanHelpers:Reverse(byref,long)
[00:23:06]       -28.10 (-4.98% of base) : 16921.dasm - System.Buffers.Text.Base64:EncodeToUtf8(System.ReadOnlySpan`1[Byte],System.Span`1[Byte],byref,byref,bool):int
[00:23:06]      -116.50 (-4.84% of base) : 9556.dasm - FractalPerf.Julia:Render():double:this
[00:23:06]      -243.50 (-4.49% of base) : 17565.dasm - BenchmarksGame.Mandelbrot_2:DoBench(int,System.IO.MemoryStream,bool)
[00:23:06]      -117.10 (-4.25% of base) : 9555.dasm - FractalPerf.Mandelbrot:Render():double:this
[00:23:06]        -7.67 (-1.55% of base) : 31820.dasm - System.Collections.BitArray:CopyTo(System.Array,int):this
[00:23:06]      -277.60 (-0.97% of base) : 37038.dasm - Benchstone.BenchF.LLoops:Main1(int):this
[00:23:06]      -275.85 (-0.72% of base) : 15310.dasm - Benchstone.MDBenchF.MDLLoops:Main1(int):this
[00:23:06]      -117.90 (-0.22% of base) : 59.dasm - System.Text.Unicode.Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:23:06]
[00:23:06] 14 total methods with Perf Score differences (12 improved, 2 regressed), 0 unchanged.
[00:23:06]
[00:23:06] --------------------------------------------------------------------------------
[00:23:06] Warning: SuperPMI encountered missing data during the diff. The diff summary printed above may be misleading.
[00:23:06] Missing with base JIT: 549. Missing with diff JIT: 549. Total contexts: 37864.
[00:23:06] Running asm diffs of C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\coreclr_tests.pmi.windows.x64.checked.mch
[00:25:18] Asm diffs found
[00:25:18] Creating dasm files: C:\prj\runtime\artifacts\spmi\asm.coreclr_tests.pmi.windows.x64.checked.2\base C:\prj\runtime\artifacts\spmi\asm.coreclr_tests.pmi.windows.x64.checked.2\diff
[00:25:19] Differences found. To replay SuperPMI use:
[00:25:19]
[00:25:19] set COMPlus_JitDisasm=*
[00:25:19] set COMPlus_JitUnwindDump=*
[00:25:19] set COMPlus_JitEHDump=*
[00:25:19] set COMPlus_NgenDisasm=*
[00:25:19] set COMPlus_NgenUnwindDump=*
[00:25:19] set COMPlus_NgenEHDump=*
[00:25:19] set COMPlus_JitDiffableDasm=1
[00:25:19] set COMPlus_JitEnableNoWayAssert=1
[00:25:19] set COMPlus_JitNoForceFallback=1
[00:25:19] set COMPlus_JitDisasmWithGC=1
[00:25:19] C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\superpmi.exe  -c ### C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\clrjit.dll C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\coreclr_tests.pmi.windows.x64.checked.mch
[00:25:19]
[00:25:19] Total bytes of base: 122933472
[00:25:19] Total bytes of diff: 122933960
[00:25:19] Total bytes of delta: 488 (0.00% of base)
[00:25:19] Generated asm is located under C:\prj\runtime\artifacts\spmi\asm.coreclr_tests.pmi.windows.x64.checked.2\base C:\prj\runtime\artifacts\spmi\asm.coreclr_tests.pmi.windows.x64.checked.2\diff
[00:25:19] Textual differences found in generated asm.
[00:25:19] Invoking: C:\prj\jitutils\bin\jit-analyze.exe --md C:\prj\runtime\artifacts\spmi\asm.coreclr_tests.pmi.windows.x64.checked.2\summary.md -r --base C:\prj\runtime\artifacts\spmi\asm.coreclr_tests.pmi.windows.x64.checked.2\base --diff C:\prj\runtime\artifacts\spmi\asm.coreclr_tests.pmi.windows.x64.checked.2\diff --metrics PerfScore
[00:25:19] Found 5 files with textual diffs.
[00:25:19]
[00:25:19] Summary of Perf Score diffs:
[00:25:19] (Lower is better)
[00:25:19]
[00:25:19] Total PerfScoreUnits of base: 72060.92
[00:25:19] Total PerfScoreUnits of diff: 71208.26999999999
[00:25:19] Total PerfScoreUnits of delta: -852.65 (-1.18 % of base)
[00:25:19] Total relative delta: -0.14
[00:25:19]     diff is an improvement.
[00:25:19]     relative diff is an improvement.
[00:25:19]
[00:25:19]
[00:25:19] Top file improvements (PerfScoreUnits):
[00:25:19]      -283.85 : 27323.dasm (-1.01% of base)
[00:25:19]      -281.50 : 27329.dasm (-0.75% of base)
[00:25:19]      -243.50 : 32296.dasm (-4.49% of base)
[00:25:19]       -32.70 : 31461.dasm (-4.73% of base)
[00:25:19]       -11.10 : 31418.dasm (-3.51% of base)
[00:25:19]
[00:25:19] 5 total files with Perf Score differences (5 improved, 0 regressed), 0 unchanged.
[00:25:19]
[00:25:19] Top method improvements (PerfScoreUnits):
[00:25:19]      -283.85 (-1.01% of base) : 27323.dasm - Benchstone.BenchF.LLoops:Main1(int):this
[00:25:19]      -281.50 (-0.75% of base) : 27329.dasm - Benchstone.MDBenchF.MDLLoops:Main1(int):this
[00:25:19]      -243.50 (-4.49% of base) : 32296.dasm - BenchmarksGame.Mandelbrot_2:DoBench(int,System.IO.MemoryStream,bool)
[00:25:19]       -32.70 (-4.73% of base) : 31461.dasm - request:Main(System.String[]):int
[00:25:19]       -11.10 (-3.51% of base) : 31418.dasm - one_pass:.ctor():this
[00:25:19]
[00:25:19] Top method improvements (percentages):
[00:25:19]       -32.70 (-4.73% of base) : 31461.dasm - request:Main(System.String[]):int
[00:25:19]      -243.50 (-4.49% of base) : 32296.dasm - BenchmarksGame.Mandelbrot_2:DoBench(int,System.IO.MemoryStream,bool)
[00:25:19]       -11.10 (-3.51% of base) : 31418.dasm - one_pass:.ctor():this
[00:25:19]      -283.85 (-1.01% of base) : 27323.dasm - Benchstone.BenchF.LLoops:Main1(int):this
[00:25:19]      -281.50 (-0.75% of base) : 27329.dasm - Benchstone.MDBenchF.MDLLoops:Main1(int):this
[00:25:19]
[00:25:19] 5 total methods with Perf Score differences (5 improved, 0 regressed), 0 unchanged.
[00:25:19]
[00:25:19] --------------------------------------------------------------------------------
[00:25:19] Warning: SuperPMI encountered missing data during the diff. The diff summary printed above may be misleading.
[00:25:19] Missing with base JIT: 18. Missing with diff JIT: 18. Total contexts: 253521.
[00:25:19] Running asm diffs of C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\libraries.crossgen2.windows.x64.checked.mch
[00:26:00] Asm diffs found
[00:26:00] Creating dasm files: C:\prj\runtime\artifacts\spmi\asm.libraries.crossgen2.windows.x64.checked.19\base C:\prj\runtime\artifacts\spmi\asm.libraries.crossgen2.windows.x64.checked.19\diff
[00:26:00] Differences found. To replay SuperPMI use:
[00:26:00]
[00:26:00] set COMPlus_JitDisasm=*
[00:26:00] set COMPlus_JitUnwindDump=*
[00:26:00] set COMPlus_JitEHDump=*
[00:26:00] set COMPlus_NgenDisasm=*
[00:26:00] set COMPlus_NgenUnwindDump=*
[00:26:00] set COMPlus_NgenEHDump=*
[00:26:00] set COMPlus_JitDiffableDasm=1
[00:26:00] set COMPlus_JitEnableNoWayAssert=1
[00:26:00] set COMPlus_JitNoForceFallback=1
[00:26:00] set COMPlus_JitDisasmWithGC=1
[00:26:00] C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\superpmi.exe  -c ### C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\clrjit.dll C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\libraries.crossgen2.windows.x64.checked.mch
[00:26:00]
[00:26:00] Total bytes of base: 34443139
[00:26:00] Total bytes of diff: 34443773
[00:26:00] Total bytes of delta: 634 (0.00% of base)
[00:26:00] Generated asm is located under C:\prj\runtime\artifacts\spmi\asm.libraries.crossgen2.windows.x64.checked.19\base C:\prj\runtime\artifacts\spmi\asm.libraries.crossgen2.windows.x64.checked.19\diff
[00:26:00] Textual differences found in generated asm.
[00:26:00] Invoking: C:\prj\jitutils\bin\jit-analyze.exe --md C:\prj\runtime\artifacts\spmi\asm.libraries.crossgen2.windows.x64.checked.19\summary.md -r --base C:\prj\runtime\artifacts\spmi\asm.libraries.crossgen2.windows.x64.checked.19\base --diff C:\prj\runtime\artifacts\spmi\asm.libraries.crossgen2.windows.x64.checked.19\diff --metrics PerfScore
[00:26:01] Found 11 files with textual diffs.
[00:26:01]
[00:26:01] Summary of Perf Score diffs:
[00:26:01] (Lower is better)
[00:26:01]
[00:26:01] Total PerfScoreUnits of base: 59794.14
[00:26:01] Total PerfScoreUnits of diff: 59327.54
[00:26:01] Total PerfScoreUnits of delta: -466.60 (-0.78 % of base)
[00:26:01] Total relative delta: -0.86
[00:26:01]     diff is an improvement.
[00:26:01]     relative diff is an improvement.
[00:26:01]
[00:26:01]
[00:26:01] Top file improvements (PerfScoreUnits):
[00:26:01]      -183.00 : 41113.dasm (-0.32% of base)
[00:26:01]      -125.50 : 184903.dasm (-33.05% of base)
[00:26:01]       -54.70 : 157470.dasm (-9.66% of base)
[00:26:01]       -48.00 : 184911.dasm (-15.45% of base)
[00:26:01]       -14.00 : 46375.dasm (-7.56% of base)
[00:26:01]       -10.50 : 48879.dasm (-7.46% of base)
[00:26:01]       -10.50 : 48866.dasm (-7.29% of base)
[00:26:01]        -9.65 : 184907.dasm (-2.14% of base)
[00:26:01]        -5.95 : 184915.dasm (-0.94% of base)
[00:26:01]        -2.40 : 41843.dasm (-1.02% of base)
[00:26:01]        -2.40 : 41482.dasm (-0.98% of base)
[00:26:01]
[00:26:01] 11 total files with Perf Score differences (11 improved, 0 regressed), 0 unchanged.
[00:26:01]
[00:26:01] Top method improvements (PerfScoreUnits):
[00:26:01]      -183.00 (-0.32% of base) : 41113.dasm - System.Text.Unicode.Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:26:01]      -125.50 (-33.05% of base) : 184903.dasm - System.Buffers.Text.Base64:Ssse3Encode(byref,byref,long,int,int,long,long)
[00:26:01]       -54.70 (-9.66% of base) : 157470.dasm - System.Collections.BitArray:CopyTo(System.Array,int):this
[00:26:01]       -48.00 (-15.45% of base) : 184911.dasm - System.Buffers.Text.Base64:Ssse3Decode(byref,byref,long,int,int,long,long)
[00:26:01]       -14.00 (-7.56% of base) : 46375.dasm - System.HexConverter:EncodeToUtf16_Vector128(System.ReadOnlySpan`1[System.Byte],System.Span`1[System.Char],int)
[00:26:01]       -10.50 (-7.46% of base) : 48879.dasm - System.SpanHelpers:Reverse(byref,long)
[00:26:01]       -10.50 (-7.29% of base) : 48866.dasm - System.SpanHelpers:Reverse(byref,long)
[00:26:01]        -9.65 (-2.14% of base) : 184907.dasm - System.Buffers.Text.Base64:EncodeToUtf8(System.ReadOnlySpan`1[System.Byte],System.Span`1[System.Byte],byref,byref,bool):int
[00:26:01]        -5.95 (-0.94% of base) : 184915.dasm - System.Buffers.Text.Base64:DecodeFromUtf8(System.ReadOnlySpan`1[System.Byte],System.Span`1[System.Byte],byref,byref,bool):int
[00:26:01]        -2.40 (-1.02% of base) : 41843.dasm - System.Text.ASCIIUtility:GetIndexOfFirstNonAsciiChar_Sse2(long,long):long
[00:26:01]        -2.40 (-0.98% of base) : 41482.dasm - System.Text.Latin1Utility:GetIndexOfFirstNonLatin1Char_Sse2(long,long):long
[00:26:01]
[00:26:01] Top method improvements (percentages):
[00:26:01]      -125.50 (-33.05% of base) : 184903.dasm - System.Buffers.Text.Base64:Ssse3Encode(byref,byref,long,int,int,long,long)
[00:26:01]       -48.00 (-15.45% of base) : 184911.dasm - System.Buffers.Text.Base64:Ssse3Decode(byref,byref,long,int,int,long,long)
[00:26:01]       -54.70 (-9.66% of base) : 157470.dasm - System.Collections.BitArray:CopyTo(System.Array,int):this
[00:26:01]       -14.00 (-7.56% of base) : 46375.dasm - System.HexConverter:EncodeToUtf16_Vector128(System.ReadOnlySpan`1[System.Byte],System.Span`1[System.Char],int)
[00:26:01]       -10.50 (-7.46% of base) : 48879.dasm - System.SpanHelpers:Reverse(byref,long)
[00:26:01]       -10.50 (-7.29% of base) : 48866.dasm - System.SpanHelpers:Reverse(byref,long)
[00:26:01]        -9.65 (-2.14% of base) : 184907.dasm - System.Buffers.Text.Base64:EncodeToUtf8(System.ReadOnlySpan`1[System.Byte],System.Span`1[System.Byte],byref,byref,bool):int
[00:26:01]        -2.40 (-1.02% of base) : 41843.dasm - System.Text.ASCIIUtility:GetIndexOfFirstNonAsciiChar_Sse2(long,long):long
[00:26:01]        -2.40 (-0.98% of base) : 41482.dasm - System.Text.Latin1Utility:GetIndexOfFirstNonLatin1Char_Sse2(long,long):long
[00:26:01]        -5.95 (-0.94% of base) : 184915.dasm - System.Buffers.Text.Base64:DecodeFromUtf8(System.ReadOnlySpan`1[System.Byte],System.Span`1[System.Byte],byref,byref,bool):int
[00:26:01]      -183.00 (-0.32% of base) : 41113.dasm - System.Text.Unicode.Utf8Utility:TranscodeToUtf8(long,int,long,int,byref,byref):int
[00:26:01]
[00:26:01] 11 total methods with Perf Score differences (11 improved, 0 regressed), 0 unchanged.
[00:26:01]
[00:26:01] --------------------------------------------------------------------------------
[00:26:01] Running asm diffs of C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\libraries.pmi.windows.x64.checked.mch
[00:27:09] Asm diffs found
[00:27:09] Creating dasm files: C:\prj\runtime\artifacts\spmi\asm.libraries.pmi.windows.x64.checked.1\base C:\prj\runtime\artifacts\spmi\asm.libraries.pmi.windows.x64.checked.1\diff
[00:27:10] Differences found. To replay SuperPMI use:
[00:27:10]
[00:27:10] set COMPlus_JitDisasm=*
[00:27:10] set COMPlus_JitUnwindDump=*
[00:27:10] set COMPlus_JitEHDump=*
[00:27:10] set COMPlus_NgenDisasm=*
[00:27:10] set COMPlus_NgenUnwindDump=*
[00:27:10] set COMPlus_NgenEHDump=*
[00:27:10] set COMPlus_JitDiffableDasm=1
[00:27:10] set COMPlus_JitEnableNoWayAssert=1
[00:27:10] set COMPlus_JitNoForceFallback=1
[00:27:10] set COMPlus_JitDisasmWithGC=1
[00:27:10] C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\superpmi.exe  -c ### C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\clrjit.dll C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\libraries.pmi.windows.x64.checked.mch
[00:27:10]
[00:27:10] Total bytes of base: 50530489
[00:27:10] Total bytes of diff: 50531192
[00:27:10] Total bytes of delta: 703 (0.00% of base)
[00:27:10] Generated asm is located under C:\prj\runtime\artifacts\spmi\asm.libraries.pmi.windows.x64.checked.1\base C:\prj\runtime\artifacts\spmi\asm.libraries.pmi.windows.x64.checked.1\diff
[00:27:10] Textual differences found in generated asm.
[00:27:10] Invoking: C:\prj\jitutils\bin\jit-analyze.exe --md C:\prj\runtime\artifacts\spmi\asm.libraries.pmi.windows.x64.checked.1\summary.md -r --base C:\prj\runtime\artifacts\spmi\asm.libraries.pmi.windows.x64.checked.1\base --diff C:\prj\runtime\artifacts\spmi\asm.libraries.pmi.windows.x64.checked.1\diff --metrics PerfScore
[00:27:10] Found 7 files with textual diffs.
[00:27:10]
[00:27:10] Summary of Perf Score diffs:
[00:27:10] (Lower is better)
[00:27:10]
[00:27:10] Total PerfScoreUnits of base: 3134.4100000000003
[00:27:10] Total PerfScoreUnits of diff: 2769.83
[00:27:10] Total PerfScoreUnits of delta: -364.58 (-11.63 % of base)
[00:27:10] Total relative delta: -0.92
[00:27:10]     diff is an improvement.
[00:27:10]     relative diff is an improvement.
[00:27:10]
[00:27:10]
[00:27:10] Top file improvements (PerfScoreUnits):
[00:27:10]       -76.37 : 210037.dasm (-9.63% of base)
[00:27:10]       -74.90 : 210048.dasm (-21.82% of base)
[00:27:10]       -70.07 : 210040.dasm (-18.01% of base)
[00:27:10]       -57.07 : 210041.dasm (-19.35% of base)
[00:27:10]       -50.40 : 210049.dasm (-16.85% of base)
[00:27:10]       -28.10 : 210045.dasm (-4.98% of base)
[00:27:10]        -7.67 : 173175.dasm (-1.70% of base)
[00:27:10]
[00:27:10] 7 total files with Perf Score differences (7 improved, 0 regressed), 0 unchanged.
[00:27:10]
[00:27:10] Top method improvements (PerfScoreUnits):
[00:27:10]       -76.37 (-9.63% of base) : 210037.dasm - System.Buffers.Text.Base64:DecodeFromUtf8(System.ReadOnlySpan`1[Byte],System.Span`1[Byte],byref,byref,bool):int
[00:27:10]       -74.90 (-21.82% of base) : 210048.dasm - System.Buffers.Text.Base64:Avx2Encode(byref,byref,long,int,int,long,long)
[00:27:10]       -70.07 (-18.01% of base) : 210040.dasm - System.Buffers.Text.Base64:Avx2Decode(byref,byref,long,int,int,long,long)
[00:27:10]       -57.07 (-19.35% of base) : 210041.dasm - System.Buffers.Text.Base64:Ssse3Decode(byref,byref,long,int,int,long,long)
[00:27:10]       -50.40 (-16.85% of base) : 210049.dasm - System.Buffers.Text.Base64:Ssse3Encode(byref,byref,long,int,int,long,long)
[00:27:10]       -28.10 (-4.98% of base) : 210045.dasm - System.Buffers.Text.Base64:EncodeToUtf8(System.ReadOnlySpan`1[Byte],System.Span`1[Byte],byref,byref,bool):int
[00:27:10]        -7.67 (-1.70% of base) : 173175.dasm - System.Collections.BitArray:CopyTo(System.Array,int):this
[00:27:10]
[00:27:10] Top method improvements (percentages):
[00:27:10]       -74.90 (-21.82% of base) : 210048.dasm - System.Buffers.Text.Base64:Avx2Encode(byref,byref,long,int,int,long,long)
[00:27:10]       -57.07 (-19.35% of base) : 210041.dasm - System.Buffers.Text.Base64:Ssse3Decode(byref,byref,long,int,int,long,long)
[00:27:10]       -70.07 (-18.01% of base) : 210040.dasm - System.Buffers.Text.Base64:Avx2Decode(byref,byref,long,int,int,long,long)
[00:27:10]       -50.40 (-16.85% of base) : 210049.dasm - System.Buffers.Text.Base64:Ssse3Encode(byref,byref,long,int,int,long,long)
[00:27:10]       -76.37 (-9.63% of base) : 210037.dasm - System.Buffers.Text.Base64:DecodeFromUtf8(System.ReadOnlySpan`1[Byte],System.Span`1[Byte],byref,byref,bool):int
[00:27:10]       -28.10 (-4.98% of base) : 210045.dasm - System.Buffers.Text.Base64:EncodeToUtf8(System.ReadOnlySpan`1[Byte],System.Span`1[Byte],byref,byref,bool):int
[00:27:10]        -7.67 (-1.70% of base) : 173175.dasm - System.Collections.BitArray:CopyTo(System.Array,int):this
[00:27:10]
[00:27:10] 7 total methods with Perf Score differences (7 improved, 0 regressed), 0 unchanged.
[00:27:10]
[00:27:10] --------------------------------------------------------------------------------
[00:27:10] Running asm diffs of C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\libraries_tests.pmi.windows.x64.checked.mch
[00:29:13] SuperPMI encountered missing data. Missing with base JIT: 41. Missing with diff JIT: 41. Total contexts: 267537.
[00:29:13] Asm diffs summary:
[00:29:13]   Summary Markdown file: C:\prj\runtime\artifacts\spmi\diff_summary.28.md
[00:29:13]   Asm diffs in 5 MCH files:
[00:29:13]     C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\aspnet.run.windows.x64.checked.mch
[00:29:13]     C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\benchmarks.run.windows.x64.checked.mch
[00:29:13]     C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\coreclr_tests.pmi.windows.x64.checked.mch
[00:29:13]     C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\libraries.crossgen2.windows.x64.checked.mch
[00:29:13]     C:\prj\runtime\artifacts\spmi\mch\f2a217c4-2a69-4308-99ce-8292c6763776.windows.x64\libraries.pmi.windows.x64.checked.mch
PS C:\prj\runtime>

@EgorBo
Copy link
Member Author

EgorBo commented Jun 9, 2022

@dotnet/jit-contrib @tannergooding @jakobbotsch PTAL
No PerfScore regressions but with size regressions, e.g.: https://www.diffchecker.com/KlfLyWW2 (clearly it's faster now since we removed memory loads out of the main loop)

@EgorBo EgorBo marked this pull request as ready for review June 9, 2022 12:05
Copy link
Member

@tannergooding tannergooding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a reasonable fix to me.

const unsigned ssaNum = GetSsaNumForLocalVarDef(tree);
if (ssaNum != SsaConfig::RESERVED_SSA_NUM)
{
BasicBlock* defBlock = lvaTable[lclNum].GetPerSsaData(ssaNum)->GetBlock();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: lvaTable[lclNum]. -> lvaGetDesc(lclNum)->.

General comment on the algorithm: this walks only one step up in the def chain, so if we have something like this:

var a = const;
for (...) {
    var b = a;
    Use(b);
}

We will still propagate const to Use.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SingleAccretion I don't see why it would.
When we're at Use(b) and we query SsaData()->Block from b we get a's Block and it leads to "avoid propagating" path

Copy link
Member Author

@EgorBo EgorBo Jun 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, actually for your case b is going to be replaced with a in an earlier phase VN based copy prop

Copy link
Contributor

@SingleAccretion SingleAccretion Jun 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we're at Use(b) and we query SsaData()->Block from b we get a's Block and it leads to "avoid propagating" path

If I annotate this with blocks:

BB01:
var a = const;

for (...) {
BB02:
    var b = a; // b:d:1
    Use(b);    // b:u:1
}

I am pretty sure that when we query the def block for b:u:1, we'd get BB02, since the def b:d:1 occurs inside it.

Ah, actually for your case b is going to be replaced with a in an earlier phase VN based copy prop

I agree that copy propagation helps us here; not sure by how much because of the liveness constraints it has.

In any case, I also agree that there is no reason, for now, to complicate the code with a full UD chain walk, because we are pretty much targeting people hoisting constants out of loops by hands.

@EgorBo
Copy link
Member Author

EgorBo commented Jun 10, 2022

@SingleAccretion does it look good now?

Copy link
Contributor

@SingleAccretion SingleAccretion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, code changes look good.

I did not look at the regressions; presuming the are "expected".

@EgorBo
Copy link
Member Author

EgorBo commented Jun 10, 2022

I did not look at the regressions; presuming the are "expected".

Yeah, I ran SPMI with -metrics PerfScore and didn't hit any regressions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JIT: AssertProp propagates const vector back to loop body
6 participants