You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JIT: Incorrect result computed with forward sub #65104
The following program computes a wrong result on arm64.
Reproduction Steps
// Generated by Fuzzlyn v1.5 on 2022-02-08 16:14:33// Run on Arm64 Linux// Seed: 10380378818647712015// Reduced from 169.3 KiB to 0.7 KiB in 00:44:43// Debug: Outputs 0// Release: Outputs 1publicclassC0{}publicstructS0{publicuintF2;publicC0F4;publicuintF5;publicintF7;publicshortF9;publicS0(uintf2,intf7):this(){F7=f7;}publicintM21(uintarg0){S0[]var0=newS0[]{newS0(0,0)};varvr1=newS0(this.F2++,Program.M23());returnProgram.s_8.F7;}}publicclassProgram{publicstaticIRTs_rt;publicstaticuints_2;publicstaticS0s_8=newS0(0,1);publicstaticvoidMain(){s_rt=newC();S0vr8=default(S0);ushortvr9=(ushort)(vr8.F2%(ushort)vr8.M21(s_2));s_rt.WriteLine(vr9);}publicstaticbyteM23(){returndefault(byte);}}publicinterfaceIRT{voidWriteLine<T>(Tvalue);}publicclassC:IRT{publicvoidWriteLine<T>(Tvalue){System.Console.WriteLine(value);}}
Expected behavior
Same result in debug and release.
Actual behavior
Differing results.
Regression?
Yes, does not repro with COMPlus_JitNoForwardSub=1.
fgMorphModToSubMulDiv is invoked in preorder which means we don't have up to date flag info for the child operands. This makes doing interference checking difficult. So, either we can
(a) always spill
(b) do some "cheap" analysis to avoid spilling for unaliased locals and constants
(c) try moving this optimization to post-order
Going to pursue (a) but am tempted by (c).
ghost added
in-prThere is an active PR which will close this issue when it is merged
Activity
AndyAyersMS commentedon Feb 9, 2022
Suspect
fgMorphModToSubMulDivis doing an unsafe reordering.AndyAyersMS commentedon Feb 10, 2022
fgMorphModToSubMulDivis invoked in preorder which means we don't have up to date flag info for the child operands. This makes doing interference checking difficult. So, either we can(a) always spill
(b) do some "cheap" analysis to avoid spilling for unaliased locals and constants
(c) try moving this optimization to post-order
Going to pursue (a) but am tempted by (c).