-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix value numbering when selecting a constant #18627
Conversation
I was originally going to wait for green light in #18235 since it has already been assigned, however I was trying to familiarize myself with the JIT tools and the fix seemed so simple that I might as well submit it. I am not 100% sure which parts of
The diffs on the test cases are: ; Assembly listing for method C0:.ctor():this
; Emitting BLENDED_CODE for X64 CPU with AVX
; optimized code
; rsp based frame
; partially interruptible
; Final local variable assignments
;
;* V00 this [V00 ] ( 0, 0 ) ref -> zero-ref this class-hnd
;# V01 OutArgs [V01 ] ( 1, 1 ) lclBlk ( 0) [rsp+0x00]
;
; Lcl frame size = 0
G_M41541_IG01:
G_M41541_IG02:
ret
; Total bytes of code 1, prolog size 0 for method C0:.ctor():this
; ============================================================
Unwind Info:
>> Start offset : 0x000000 (not in unwind data)
>> End offset : 0xd1ffab1e (not in unwind data)
Version : 1
Flags : 0x00
SizeOfProlog : 0x00
CountOfUnwindCodes: 0
FrameRegister : none (0)
FrameOffset : N/A (no FrameRegister) (Value=0)
UnwindCodes :
; Assembly listing for method Program:Main():int
; Emitting BLENDED_CODE for X64 CPU with AVX
; optimized code
; rsp based frame
; partially interruptible
; Final local variable assignments
;
;* V00 loc0 [V00 ] ( 0, 0 ) ref -> zero-ref class-hnd exact
-; V01 loc1 [V01,T02] ( 5, 5 ) long -> rax
+; V01 loc1 [V01,T01] ( 3, 3 ) long -> rax
; V02 OutArgs [V02 ] ( 1, 1 ) lclBlk (32) [rsp+0x00]
-; V03 tmp1 [V03,T00] ( 7, 14 ) ref -> rax class-hnd exact
-; V04 cse0 [V04,T01] ( 8, 8 ) int -> rax
+; V03 tmp1 [V03,T00] ( 5, 10 ) ref -> rax class-hnd exact
;
; Lcl frame size = 40
G_M40942_IG01:
sub rsp, 40
G_M40942_IG02:
mov rcx, 0xD1FFAB1E
call CORINFO_HELP_NEWSFAST
mov byte ptr [rax+8], -1
movzx rax, byte ptr [rax+8]
+ or eax, 0x3E8
movsxd rax, eax
cmp rax, 0x3FF
je SHORT G_M40942_IG04
xor eax, eax
G_M40942_IG03:
add rsp, 40
ret
G_M40942_IG04:
mov eax, 100
G_M40942_IG05:
add rsp, 40
ret
-; Total bytes of code 55, prolog size 4 for method Program:Main():int
+; Total bytes of code 60, prolog size 4 for method Program:Main():int
; ============================================================
Unwind Info:
>> Start offset : 0x000000 (not in unwind data)
>> End offset : 0xd1ffab1e (not in unwind data)
Version : 1
Flags : 0x00
SizeOfProlog : 0x04
CountOfUnwindCodes: 1
FrameRegister : none (0)
FrameOffset : N/A (no FrameRegister) (Value=0)
UnwindCodes :
CodeOffset: 0x04 UnwindOp: UWOP_ALLOC_SMALL (2) OpInfo: 4 * 8 + 8 = 40 = 0x28
; Assembly listing for method Program:.ctor():this
; Emitting BLENDED_CODE for X64 CPU with AVX
; optimized code
; rsp based frame
; partially interruptible
; Final local variable assignments
;
;* V00 this [V00 ] ( 0, 0 ) ref -> zero-ref this class-hnd
;# V01 OutArgs [V01 ] ( 1, 1 ) lclBlk ( 0) [rsp+0x00]
;
; Lcl frame size = 0
G_M48452_IG01:
G_M48452_IG02:
ret
; Total bytes of code 1, prolog size 0 for method Program:.ctor():this ; Assembly listing for method Program:Main():int
; Emitting BLENDED_CODE for X64 CPU with AVX
; optimized code
; rsp based frame
; partially interruptible
; Final local variable assignments
;
; V00 loc0 [V00,T00] ( 1, 1 ) struct (24) [rsp+0x08] do-not-enreg[SFB] must-init ld-addr-op
;* V01 loc1 [V01,T01] ( 0, 0 ) int -> zero-ref
;# V02 OutArgs [V02 ] ( 1, 1 ) lclBlk ( 0) [rsp+0x00]
;
; Lcl frame size = 32
G_M35631_IG01:
push rdi
sub rsp, 32
vzeroupper
lea rdi, [rsp+08H]
mov ecx, 6
xor rax, rax
rep stosd
G_M35631_IG02:
xor rax, rax
lea rdx, bword ptr [rsp+08H]
vxorps xmm0, xmm0
vmovdqu qword ptr [rdx], xmm0
mov qword ptr [rdx+16], rax
- mov dword ptr [reloc classVar[0xd1ffab1e]], 0x10001
+ mov dword ptr [reloc classVar[0xd1ffab1e]], 1
+ mov eax, 100
G_M35631_IG03:
add rsp, 32
pop rdi
ret
-; Total bytes of code 59, prolog size 22 for method Program:Main():int
+; Total bytes of code 64, prolog size 22 for method Program:Main():int Any feedback is appreciated. I also have two questions:
cc @dotnet/jit-contrib |
By the way, I have tried to figure out why the special casing was there to begin with, but the code was added before .NET was open-sourced, so I cannot see if there is anything in the commit message. Line 2628 in e32feb0
I am unsure if this needs to be changed as well. |
Thanks for the prospective fix! @briansull or @erozenfeld can help evaluate this change. jit-diffs without --pmi will find changes in prejitted code. Since large portions of the framework assemblies are prejitted it is worth running jit-diffs in that mode -- you will get some coverage that jit-diff --pmi can't get. You don't need to run jit-diff in prejit mode over tests. |
Also I sent you a collaborator invite. We can assign issues to you once you accept. |
I have accepted the invite. 👍
|
This does not fix the following case: // Generated by Fuzzlyn on 2018-06-03 22:28:26
// Seed: 12435988927817691522
// Reduced from 70.9 KB to 0.4 KB
// Debug: Outputs 64447
// Release: Outputs -1089
class C0
{
public short F1;
public C0(short f1)
{
F1 = f1;
}
}
class C1
{
public C0 F9;
public C1(C0 f9)
{
F9 = f9;
}
}
public class Program
{
public static void Main()
{
var vr61 = new C1(new C0(-20454));
int vr63 = (ushort)(23487 | (long)vr61.F9.F1);
System.Console.WriteLine(vr63);
}
} I am taking a look... |
That case is probably the same as #18238. it looks like the cast disappears:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes Look Good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I found that commit (by @briansull in 2013). This code was in the original versions of VNApplySelectorsAssignTypeCoerce and VNApplySelectorsAssignTypeCoerce and the only comments about these methods in the commit message were:
|
Suspect the test failures were unrelated. Let's retry them.... @dotnet-bot retest Windows_NT x64 Release CoreFX Tests @jakobbotsch can you add the standard license header to the new test cases, and also add them to the respective arm32 and arm64 test list files (see tests\arm*\tests.lst). Once you add the tests to the list files, this PR and #18563 will have merge conflicts. @BruceForstall @jashook any thought on how to make those list files more automerge-friendly? |
When applying selectors, constants were special-cased to not require any type casts. However this is wrong if a narrowing needs to be performed. Fix #18235
I've amended those changes. |
Thanks! I'll sort out the test list issues over in my PR. |
Master PR dotnet#18627 When applying selectors, constants were special-cased to not require any type casts. However this is wrong if a narrowing needs to be performed. Fix #18235
Master PR dotnet#18627 When applying selectors, constants were special-cased to not require any type casts. However this is wrong if a narrowing needs to be performed. Fix #18235
Master PR #18627 When applying selectors, constants were special-cased to not require any type casts. However this is wrong if a narrowing needs to be performed. Fix #18235
When applying selectors, constants were special-cased to not require any type casts. However this is wrong if a narrowing needs to be performed. Fix dotnet/coreclr#18235 Commit migrated from dotnet/coreclr@4e237f0
When applying selectors, constants were special-cased to not require any
type casts. However this is wrong if a narrowing needs to be performed.
Fix #18235
I have fixed this problem by removing the special casing. The diff is easier to read without whitespace (there should only be deletions).