Disable folding of implementation-defined casts - #53782

Merged
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts
Jul 7, 2021
Merged

Disable folding of implementation-defined casts#53782
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts

Conversation

@SingleAccretion

@SingleAccretionSingleAccretion commented Jun 6, 2021

Copy link
Copy Markdown
Contributor

With #51440 merged, it is now easy to do the intended second part of that PR and disable folding of all implementation-defined float/double -> integer casts. This is a temporary solution to #47478, but without it I will not be able to move forward with the casts work as a lot of this has so far been masked by the fact that problematic conversions were being morphed into calls and thus not getting folded.

For the diffs, the expectation is that there will be some regressions in coreclr_tests.

Windows x64
Running asm diffs of coreclr_tests.pmi.windows.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49048
Total bytes of diff: 50724
Total bytes of delta: 1676 (3.42% of base)
diff is a regression.
Top method regressions (bytes):
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
95 (30.16% of base) - FloatOvfToInt:TestValuesDoubleInt():int
95 (30.16% of base) - FloatOvfToInt:TestValuesFloatInt():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
59 ( 0.23% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
49 (13.14% of base) - ILGEN_0xe696696:main():int
42 (15.05% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
42 (700.00% of base) - ILGEN_1806854430:main():int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
39 (31.97% of base) - FloatOvfToInt:TestValuesFloatShort():int
38 (19.29% of base) - ILGEN_622380794:main():int
33 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
32 (25.00% of base) - FloatOvfToInt:TestValuesFloatInt():int
32 (25.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (bytes):
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-4 (-5.71% of base) - C:L(float):float
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
Top method regressions (percentages):
42 (700.00% of base) - ILGEN_1806854430:main():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
14 (38.89% of base) - ConvTest:test8():ushort
14 (38.89% of base) - ConvTest:test8():ushort
17 (37.78% of base) - ILGEN_0x64f58bd0:Method_0x1bb0(int,long,float,int,int):int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
Top method improvements (percentages):
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-4 (-5.71% of base) - C:L(float):float
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
67 total methods with Code Size differences (9 improved, 58 regressed), 0 unchanged.
Windows x86
Running asm diffs of coreclr_tests.pmi.windows.x86.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 50715
Total bytes of diff: 52539
Total bytes of delta: 1824 (3.60% of base)
diff is a regression.
Top method regressions (bytes):
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleByte():int
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleShort():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatByte():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatShort():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (23.50% of base) - ILGEN_0xe696696:main():int
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
48 (12.66% of base) - DevDiv_590771:ILGEN_METHOD(long,ushort,int,int,ushort,int):byte
47 ( 8.58% of base) - FloatOvfToInt:TestValuesDoubleInt():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
37 ( 6.75% of base) - FloatOvfToInt:TestValuesFloatInt():int
36 (600.00% of base) - ILGEN_1806854430:main():int
36 (13.90% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
34 ( 5.87% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
32 (12.85% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-8 (-5.23% of base) - C:Main():int
-8 (-7.02% of base) - C:L(float):float
Top method regressions (percentages):
36 (600.00% of base) - ILGEN_1806854430:main():int
24 (400.00% of base) - ILGEN_622380794:main():int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
21 (75.00% of base) - ILGEN_0xb6f84258:Main():int
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test7():ubyte
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test7():ubyte
3 (37.50% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
Top method improvements (percentages):
-8 (-7.02% of base) - C:L(float):float
-8 (-5.23% of base) - C:Main():int
61 total methods with Code Size differences (2 improved, 59 regressed), 0 unchanged.
Linux x64
Running asm diffs of coreclr_tests.pmi.Linux.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 48680
Total bytes of diff: 50694
Total bytes of delta: 2014 (4.14% of base)
diff is a regression.
Top method regressions (bytes):
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
137 (49.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
131 (47.29% of base) - FloatOvfToInt:TestValuesDoubleShort():int
131 (47.29% of base) - FloatOvfToInt:TestValuesFloatShort():int
115 (37.95% of base) - FloatOvfToInt:TestValuesFloatInt():int
115 (37.95% of base) - FloatOvfToInt:TestValuesDoubleInt():int
78 (36.11% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
60 (15.67% of base) - ILGEN_0xe696696:main():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
53 ( 0.22% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
52 (44.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
52 (44.83% of base) - FloatOvfToInt:TestValuesDoubleInt():int
44 (733.33% of base) - ILGEN_1806854430:main():int
42 (16.03% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
38 (16.24% of base) - ILGEN_622380794:main():int
34 (26.77% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
Top method improvements (bytes):
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-8 (-13.11% of base) - C:L(float):float
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
Top method regressions (percentages):
44 (733.33% of base) - ILGEN_1806854430:main():int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test2():short
23 (69.70% of base) - ConvTest:test2():short
22 (66.67% of base) - ConvTest:test7():ubyte
22 (66.67% of base) - ConvTest:test7():ubyte
21 (63.64% of base) - ConvTest:test8():ushort
21 (63.64% of base) - ConvTest:test8():ushort
18 (54.55% of base) - ConvTest:test9():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test9():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
Top method improvements (percentages):
-8 (-13.11% of base) - C:L(float):float
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
65 total methods with Code Size differences (8 improved, 57 regressed), 2 unchanged.
Linux ARM64
Running asm diffs of coreclr_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 51232
Total bytes of diff: 54080
Total bytes of delta: 2848 (5.56% of base)
diff is a regression.
Top method regressions (bytes):
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (35.53% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
64 (12.40% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (18.52% of base) - FloatOvfToInt:TestValuesFloatLong():int
60 (18.52% of base) - FloatOvfToInt:TestValuesDoubleLong():int
60 (14.15% of base) - ILGEN_0xe696696:main():int
52 (260.00% of base) - ILGEN_1806854430:main():int
44 (26.83% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
44 (12.36% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
44 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
40 ( 7.75% of base) - ILGEN_0x57cc69ce:Method_0x183df1b1():int
Top method improvements (bytes):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
Top method regressions (percentages):
52 (260.00% of base) - ILGEN_1806854430:main():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
28 (53.85% of base) - ILGEN_0x77e65197:Main():int
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test7():ubyte
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test7():ubyte
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (percentages):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
78 total methods with Code Size differences (1 improved, 77 regressed), 2 unchanged.
Running asm diffs of libraries_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 932
Total bytes of diff: 968
Total bytes of delta: 36 (3.86% of base)
diff is a regression.
Top method regressions (bytes):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
Top method regressions (percentages):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
1 total methods with Code Size differences (0 improved, 1 regressed), 6 unchanged.
Linux ARM
Running asm diffs of coreclr_tests.pmi.Linux.arm.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49502
Total bytes of diff: 52992
Total bytes of delta: 3490 (7.05% of base)
diff is a regression.
Top method regressions (bytes):
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleShort():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleByte():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatShort():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatByte():int
122 (26.18% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (34.96% of base) - ILGEN_622380794:main():int
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
84 (28.77% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
70 ( 0.29% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,int,ushort,double,long,long):int
66 (16.10% of base) - ILGEN_0xe696696:main():int
66 (1,100.00% of base) - ILGEN_1806854430:main():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
66 (12.94% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (1,000.00% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-10 (-11.36% of base) - C:L(float):float
Top method regressions (percentages):
66 (1,100.00% of base) - ILGEN_1806854430:main():int
60 (1,000.00% of base) - ILGEN_622380794:main():int
12 (150.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
44 (146.67% of base) - ILGEN_0xb6f84258:Main():int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
26 (59.09% of base) - ConvTest:test2():short
26 (59.09% of base) - ConvTest:test8():ushort
26 (59.09% of base) - ConvTest:test1():byte
26 (59.09% of base) - ConvTest:test7():ubyte
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
24 (54.55% of base) - ConvTest:test1():byte
24 (54.55% of base) - ConvTest:test2():short
24 (54.55% of base) - ConvTest:test7():ubyte
24 (54.55% of base) - ConvTest:test8():ushort
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
Top method improvements (percentages):
-10 (-11.36% of base) - C:L(float):float
66 total methods with Code Size differences (1 improved, 65 regressed), 1 unchanged.

Which the replays confirm.

Closes#51346.
Closes#47374.

It is not very effective right now because the "bad" combinations of
types are morphed into helpers too early, but it will be helpful when
we enable folding outside of the importer for those cases too.
It now fails on Windows x86, where many of the
previous similar failures were observed.
@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 6, 2021
@SingleAccretionSingleAccretion changed the title Disable folding for implementation-defined castsDisable folding of implementation-defined castsJun 6, 2021
@SingleAccretion
SingleAccretionforce-pushed the Disable-Folding-For-Implementation-Defined-Casts branch from d47687b to d13b563CompareJune 6, 2021 16:51
@SingleAccretion
SingleAccretion marked this pull request as ready for review June 7, 2021 20:19
@tannergooding

Copy link
Copy Markdown
Member

CC. @dotnet/jit-contrib, community PR

@JulieLeeMSFT

Copy link
Copy Markdown
Member

@kunalspathak PTAL for community PR.

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added some questions. Could you share some of the sample diffs that you see in the test (just to understand how this works underlying). Also, did you check asmdiffs on benchmarks/libraries?

Comment threadsrc/coreclr/jit/valuenum.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Also, did you check asmdiffs on benchmarks/libraries?

Yep, the PR's header is for results of running SPMI over all available collections, so, no diffs outside tests.

Could you share some of the sample diffs that you see in the test (just to understand how this works underlying).

Will recollect the diffs and share the samples.

@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Case 1: ILGEN_0x44f8f663:Method_0x2e75f3b4, 76 (133.33% of base):

 G_M64081_IG01:
sub rsp, 40
-+ vzeroupper+
G_M64081_IG02:
movsx rcx, cl
xor ecx, 5
@@ -25,22 +26,41 @@ G_M64081_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, isz
add rcx, rax
mov rax, rcx
shr rax, 32
- jne SHORT G_M64081_IG03+ jne SHORT G_M64081_IG04
xor ecx, ecx
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
- xor ecx, ecx- call CORINFO_HELP_OVERFLOW+ vmovsd xmm0, qword ptr [reloc @RWD00]+ call CORINFO_HELP_DBL2ULNG
; gcr arg pop 0
- int3- ;; bbWeight=1 PerfScore 5.75-G_M64081_IG03: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref+ vxorps xmm0, xmm0+ vcvtsi2ss xmm0, rax+ vcvtss2sd xmm0, xmm0+ call CORINFO_HELP_DBL2ULNG+ ; gcr arg pop 0+ mov rdx, 0xD1FFAB1E+ imul rax, rdx+ mov rdx, 0xD1FFAB1E+ add rax, rdx+ jo SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jg SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jl SHORT G_M64081_IG04+ ;; bbWeight=1 PerfScore 23.83+G_M64081_IG03: ; , epilog, nogc, extend+ add rsp, 40+ ret+ ;; bbWeight=1 PerfScore 1.25+G_M64081_IG04: ; gcVars=0000000000000000 {}, gcrefRegs=00000000 {}, byrefRegs=00000000 {}, gcvars, byref
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
int3
;; bbWeight=0 PerfScore 0.00
+RWD00 dq 4D95800D5C7F3082h ; 5.66058935e+65

Here the early importer folding is blocked, due to the new checks in gtFoldExprConst:

 [ 1] 100 (0x064) nop
[ 1] 101 (0x065) ldc.r8 5.6605893542014790e+65
[ 2] 110 (0x06e) conv.u
-Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- ulong <- double- [000024] ------------ \--* CNS_DBL double 5.6605893542014790e+65-Bashed to long constant:- [000025] ------------ * CNS_INT long 0-
[ 2] 111 (0x06f) conv.r4
-Folding fp operator with constant nodes into a fp constant:- [000026] ------------ * CAST float <- long- [000025] ------------ \--* CNS_INT long 0-Bashed to fp constant:- [000026] ------------ * CNS_DBL float 0.0000000000000000-
[ 2] 112 (0x070) conv.u8
-Folding long operator with constant nodes into a constant:- [000027] ------------ * CAST long <- ulong <- float- [000026] ------------ \--* CNS_DBL float 0.0000000000000000-Bashed to long constant:- [000027] ------------ * CNS_INT long 0-
[ 2] 113 (0x071) mul
[ 1] 114 (0x072) ldc.r4 2281166340096.0000
[ 2] 119 (0x077) ldc.r8 -1.4862075407321284e+46
@@ -475,7 +457,10 @@ STMT00009 (IL ???... ???)
[000095] ---X-------- \--* ADD_ovfl long
[000028] ------------ +--* MUL long
[000018] ------------ | +--* CNS_INT long -0xf925aa1447c2972
- [000027] ------------ | \--* CNS_INT long 0+ [000027] ------------ | \--* CAST long <- ulong <- float+ [000026] ------------ | \--* CAST float <- long+ [000025] ------------ | \--* CAST long <- ulong <- double+ [000024] ------------ | \--* CNS_DBL double 5.6605893542014790e+65
[000094] ---X-------- \--* SUB_ovfl long

Case 2: ILGEN_1806854430:main():int, 42 (700.00% of base):

- mov eax, 100- ;; bbWeight=1 PerfScore 0.25+ vcvttss2si rax, qword ptr [reloc @RWD00]+ cmp rax, 0xD1FFAB1E+ setl dl+ movzx rdx, dl+ movsxd rdx, edx+ cmp rdx, rax+ setg al+ movzx rax, al+ cmp eax, 0xD1FFAB1E+ seta al+ movzx rax, al+ add eax, 100+ ;; bbWeight=1 PerfScore 12.00
G_M58196_IG03: ; , epilog, nogc, extend
ret
;; bbWeight=1 PerfScore 1.00
+RWD00 dd 63E756A3h ; 8.53488e+21

This time, local assertion propagation does not result in gtFoldExprConst folding the expressions in post-order morph:

@@ -518,56 +512,35 @@ Assertion prop in BB01:
Constant Assertion: V00 == 8.53488e+21 index=#01, mask=0000000000000001
[000020] ------------ * CNS_DBL float 8.5348814290707441e+21
-Folding long operator with constant nodes into a constant:- [000021] ------------ * CAST long <- float- [000020] -----+------ \--* CNS_DBL float 8.5348814290707441e+21-Bashed to long constant:- [000021] ------------ * CNS_INT long -0x8000000000000000--Folding operator with constant nodes into a constant:- [000023] ------------ * GT int- [000022] -----+------ +--* CNS_INT long 0x45E23077- [000021] -----+------ \--* CNS_INT long -0x8000000000000000-Bashed to int constant:- [000023] ------------ * CNS_INT int 1--Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- int- [000023] -----+------ \--* CNS_INT int 1-Bashed to long constant:- [000025] ------------ * CNS_INT long 1

Case 3: ConvTest:test1():byte, 16 (44.44% of base):

 G_M30804_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,22 @@ G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- xor ecx, ecx+ vcvttsd2si ecx, dword ptr [reloc @RWD00]+ movsx rsi, cl+ mov ecx, esi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- xor eax, eax- ;; bbWeight=1 PerfScore 4.75+ movsx rax, sil+ ;; bbWeight=1 PerfScore 12.00
G_M30804_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)

Here, VN block takes hold:

 N001 [000002] CNS_DBL -nan(ind) => $140 {DblCns[-nan(ind)]}
VNForCastOper(int) is $41
-N002 [000013] CAST => $42 {IntCns 0x80000000}- VNForCastOper(byte) is $43-N003 [000003] CAST => $44 {IntCns 0}-N004 [000004] LCL_VAR V01 tmp1 d:1 => $44 {IntCns 0}-N005 [000005] ASG => $44 {IntCns 0}+N002 [000013] CAST => $180 {Cast($140, $41)}+ VNForCastOper(byte) is $42+N003 [000003] CAST => $181 {Cast($180, $42)}+N004 [000004] LCL_VAR V01 tmp1 d:1 => $181 {Cast($180, $42)}+N005 [000005] ASG => $181 {Cast($180, $42)}
***** BB01, STMT00001(after)
-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $44-N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $42+N005 ( 10, 12) [000005] -A------R--- * ASG int $181+N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $181+N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $181+N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $180
N001 ( 3, 4) [000002] ------------ \--* CNS_DBL double -nan(ind) $140

This means no constant propagation in assertion prop:

-After constant propagation on [000003]:-STMT00001 (IL 0x00A... ???)-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44- [000016] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N003 ( 1, 3) [000005] -A------R--- * ASG int $44-N002 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N001 ( 1, 1) [000016] ------------ \--* CNS_INT int 0 $44--After constant propagation on [000007]:-STMT00002 (IL ???... ???)-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void- [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44-ReMorphing args for 8.CALL:-argSlots=1, preallocatedArgCount=4, nextSlotNum=4, nextSlotByteOffset=32, outgoingArgSpaceSize=32-ArgTable for 8.CALL after fgMorphArgs:-fgArgTabEntry[arg 0 17.CNS_INT int (By ref), 1 reg: rcx, byteAlignment=8, lateArgInx=0, processed]--optVNAssertionPropCurStmt morphed tree:-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void-N002 ( 1, 1) [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44--After constant propagation on [000015]:-STMT00003 (IL 0x01A... ???)-N003 ( 3, 4) [000009] ------------ * RETURN int $182- [000018] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N002 ( 2, 2) [000009] ------------ * RETURN int $182-N001 ( 1, 1) [000018] ------------ \--* CNS_INT int 0 $44

Case 4: ConvTest:test4():long, -3 (-5.77% of base):

-; Lcl frame size = 40+; Lcl frame size = 32
G_M60593_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,21 @@ G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- mov rcx, 0xD1FFAB1E+ vcvttsd2si rsi, qword ptr [reloc @RWD00]+ mov rcx, rsi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- mov rax, 0xD1FFAB1E- ;; bbWeight=1 PerfScore 4.75+ mov rax, rsi+ ;; bbWeight=1 PerfScore 11.75
G_M60593_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)+-; Total bytes of code 52, prolog size 4, PerfScore 11.45, instruction count 9, allocated bytes for code 52 (MethodHash=1dad134e) for method ConvTest:test4():long+; Total bytes of code 49, prolog size 5, PerfScore 19.65, instruction count 12, allocated bytes for code 49 (MethodHash=1dad134e) for method ConvTest:test4():long

This is another case of no folding in VN:

-N002 [000003] CAST => $180 {LngCns: 0x8000000000000000}-N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {LngCns: 0x8000000000000000}-N004 [000005] ASG => $180 {LngCns: 0x8000000000000000}+N002 [000003] CAST => $180 {Cast($140, $41)}+N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {Cast($140, $41)}+N004 [000005] ASG => $180 {Cast($140, $41)}

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution!

Where they originally were.
@kunalspathak

Copy link
Copy Markdown
Contributor

@SingleAccretion - do you mind taking a look into failures to make sure they are not related to your changes?

@SingleAccretion

SingleAccretion commented Jul 7, 2021

Copy link
Copy Markdown
ContributorAuthor

do you mind taking a look into failures to make sure they are not related to your changes?

@kunalspathak yes of course. Unfortunately the CI is not in the greatest of shapes right now :(.

  1. Build Android x64 Release AllSubsets_Mono_RuntimeTests - log, looks like an infrastructure problem:
[21:26:28] fail: Cannot find a device with app=package:net.dot.JIT_CodeGenBringUpTests, please check that a device is attached
XHarness exit code: 85 (ADB_DEVICE_ENUMERATION_FAILURE)
Test Harness Exitcode is : 85
  1. Build tvOS arm64 Release AllSubsets_Mono - restore failed:
.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : (NETCORE_ENGINEERING_TELEMETRY=Restore) Failed to download package 'Microsoft.Private.Intellisense.5.0.0-preview-20201009.2' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.private.intellisense/5.0.0-preview-20201009.2/microsoft.private.intellisense.5.0.0-preview-20201009.2.nupkg'.
Response status code does not indicate success: 503 (Service Unavailable - TF10216: Azure DevOps services are currently unavailable. Try again later. Activity Id: 84ef9393-5dd8-434a-80b7-f2eb40580efb (DevOps Activity ID: 84EF9393-5DD8-434A-80B7-F2EB40580EFB)).
  1. CoreCLR Product Build OSX arm64 checked - log, another restore failure:
2021-07-06T20:40:41.9426000Z /Users/runner/work/1/s/.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : Failed to download package 'System.Linq.4.1.0-rc2-24027' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/system.linq/4.1.0-rc2-24027/system.linq.4.1.0-rc2-24027.nupkg'. [/Users/runner/work/1/s/src/tests/Common/external/external.csproj] [/Users/runner/work/1/s/src/tests/build.proj]
  1. Libraries Test Run checked coreclr Linux_musl arm Release - log, this time a real test failure:
 Discovering: System.Text.Encoding.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.Text.Encoding.Tests (found 338 of 341 test cases)
Starting: System.Text.Encoding.Tests (parallel test collections = on, max threads = 4)
System.Text.Tests.TranscodingStreamTests.Read_Span(bufferLength: 1) [FAIL]
Assert.Equal() Failure
↓ (pos 4839671)
Expected: ···lmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
Actual: ···lmnopqrstuvwxyzabcdeFghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
↑ (pos 4839671)

This looks like #47444. Seeing as this is a rare failure, maybe we can extract some useful information from this run...?

  1. Libraries Test Run release coreclr Linux x64 Debug - log, another test failure:
System.Net.Http.Functional.Tests.SocketsHttpHandler_HttpClientHandler_ConnectionPooling_Test.Http2_SmallConnectionTimeout_SubsequentRequestUsesDifferentConnection(timeoutPropertyName: "PooledConnectionLifetime") [FAIL]
System.IO.IOException : Unable to write data to the transport connection: Broken pipe.
  1. runtime-dev-innerloop, build #20210706.55, runtime-dev-innerloop, Build OSX x64 release Runtime_Debug, runtime-staging (Build iOSSimulator x64 Release AllSubsets_Mono) - more restore failures.

  2. runtime-staging, many failures - log1, log2, log3 (there are others), not enough space on the device:

Standard Error:
adb: failed to install /datadisks/disk1/work/A1BB08F0/w/B3F70977/e/System.DirectoryServices.Protocols.Tests.apk: Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
  1. runtime-staging, an interpreter test failure - log

  2. runtime-staging, many System.Drawing.Imaging failures (this is Mono on Windows), PNSEs:

 System.Drawing.Imaging.Tests.MetafileTests.Ctor_InvalidEmfTypeIII_ThrowsArgumentException(emfType: 2) [FAIL]
Assert.Throws() Failure
Expected: typeof(System.ArgumentException)
Actual: typeof(System.TypeInitializationException): The type initializer for 'System.Drawing.DrawingCom' threw an exception.
---- System.TypeInitializationException : The type initializer for 'System.Drawing.DrawingCom' threw an exception.

A rich assortment to be sure...

"Real" failures seem to be HTTP one, and the interpreter one, though I find it hard to see how they could be caused by this change (note as well that it passed CI on first run, and no code changes have been committed since).

@kunalspathak
kunalspathak merged commit 527e566 into dotnet:mainJul 7, 2021
@SingleAccretion
SingleAccretion deleted the Disable-Folding-For-Implementation-Defined-Casts branch July 8, 2021 21:21
@ghostghost locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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.

System.Linq.Expressions tests are broken in CI System.Linq.Expressions tests failing on some PRs

4 participants

@SingleAccretion@tannergooding@JulieLeeMSFT@kunalspathak
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Disable folding of implementation-defined casts - #53782

Merged
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts
Jul 7, 2021
Merged

Disable folding of implementation-defined casts#53782
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts

Conversation

@SingleAccretion

@SingleAccretionSingleAccretion commented Jun 6, 2021

Copy link
Copy Markdown
Contributor

With #51440 merged, it is now easy to do the intended second part of that PR and disable folding of all implementation-defined float/double -> integer casts. This is a temporary solution to #47478, but without it I will not be able to move forward with the casts work as a lot of this has so far been masked by the fact that problematic conversions were being morphed into calls and thus not getting folded.

For the diffs, the expectation is that there will be some regressions in coreclr_tests.

Windows x64
Running asm diffs of coreclr_tests.pmi.windows.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49048
Total bytes of diff: 50724
Total bytes of delta: 1676 (3.42% of base)
diff is a regression.
Top method regressions (bytes):
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
95 (30.16% of base) - FloatOvfToInt:TestValuesDoubleInt():int
95 (30.16% of base) - FloatOvfToInt:TestValuesFloatInt():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
59 ( 0.23% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
49 (13.14% of base) - ILGEN_0xe696696:main():int
42 (15.05% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
42 (700.00% of base) - ILGEN_1806854430:main():int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
39 (31.97% of base) - FloatOvfToInt:TestValuesFloatShort():int
38 (19.29% of base) - ILGEN_622380794:main():int
33 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
32 (25.00% of base) - FloatOvfToInt:TestValuesFloatInt():int
32 (25.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (bytes):
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-4 (-5.71% of base) - C:L(float):float
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
Top method regressions (percentages):
42 (700.00% of base) - ILGEN_1806854430:main():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
14 (38.89% of base) - ConvTest:test8():ushort
14 (38.89% of base) - ConvTest:test8():ushort
17 (37.78% of base) - ILGEN_0x64f58bd0:Method_0x1bb0(int,long,float,int,int):int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
Top method improvements (percentages):
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-4 (-5.71% of base) - C:L(float):float
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
67 total methods with Code Size differences (9 improved, 58 regressed), 0 unchanged.
Windows x86
Running asm diffs of coreclr_tests.pmi.windows.x86.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 50715
Total bytes of diff: 52539
Total bytes of delta: 1824 (3.60% of base)
diff is a regression.
Top method regressions (bytes):
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleByte():int
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleShort():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatByte():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatShort():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (23.50% of base) - ILGEN_0xe696696:main():int
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
48 (12.66% of base) - DevDiv_590771:ILGEN_METHOD(long,ushort,int,int,ushort,int):byte
47 ( 8.58% of base) - FloatOvfToInt:TestValuesDoubleInt():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
37 ( 6.75% of base) - FloatOvfToInt:TestValuesFloatInt():int
36 (600.00% of base) - ILGEN_1806854430:main():int
36 (13.90% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
34 ( 5.87% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
32 (12.85% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-8 (-5.23% of base) - C:Main():int
-8 (-7.02% of base) - C:L(float):float
Top method regressions (percentages):
36 (600.00% of base) - ILGEN_1806854430:main():int
24 (400.00% of base) - ILGEN_622380794:main():int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
21 (75.00% of base) - ILGEN_0xb6f84258:Main():int
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test7():ubyte
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test7():ubyte
3 (37.50% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
Top method improvements (percentages):
-8 (-7.02% of base) - C:L(float):float
-8 (-5.23% of base) - C:Main():int
61 total methods with Code Size differences (2 improved, 59 regressed), 0 unchanged.
Linux x64
Running asm diffs of coreclr_tests.pmi.Linux.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 48680
Total bytes of diff: 50694
Total bytes of delta: 2014 (4.14% of base)
diff is a regression.
Top method regressions (bytes):
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
137 (49.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
131 (47.29% of base) - FloatOvfToInt:TestValuesDoubleShort():int
131 (47.29% of base) - FloatOvfToInt:TestValuesFloatShort():int
115 (37.95% of base) - FloatOvfToInt:TestValuesFloatInt():int
115 (37.95% of base) - FloatOvfToInt:TestValuesDoubleInt():int
78 (36.11% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
60 (15.67% of base) - ILGEN_0xe696696:main():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
53 ( 0.22% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
52 (44.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
52 (44.83% of base) - FloatOvfToInt:TestValuesDoubleInt():int
44 (733.33% of base) - ILGEN_1806854430:main():int
42 (16.03% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
38 (16.24% of base) - ILGEN_622380794:main():int
34 (26.77% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
Top method improvements (bytes):
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-8 (-13.11% of base) - C:L(float):float
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
Top method regressions (percentages):
44 (733.33% of base) - ILGEN_1806854430:main():int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test2():short
23 (69.70% of base) - ConvTest:test2():short
22 (66.67% of base) - ConvTest:test7():ubyte
22 (66.67% of base) - ConvTest:test7():ubyte
21 (63.64% of base) - ConvTest:test8():ushort
21 (63.64% of base) - ConvTest:test8():ushort
18 (54.55% of base) - ConvTest:test9():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test9():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
Top method improvements (percentages):
-8 (-13.11% of base) - C:L(float):float
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
65 total methods with Code Size differences (8 improved, 57 regressed), 2 unchanged.
Linux ARM64
Running asm diffs of coreclr_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 51232
Total bytes of diff: 54080
Total bytes of delta: 2848 (5.56% of base)
diff is a regression.
Top method regressions (bytes):
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (35.53% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
64 (12.40% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (18.52% of base) - FloatOvfToInt:TestValuesFloatLong():int
60 (18.52% of base) - FloatOvfToInt:TestValuesDoubleLong():int
60 (14.15% of base) - ILGEN_0xe696696:main():int
52 (260.00% of base) - ILGEN_1806854430:main():int
44 (26.83% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
44 (12.36% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
44 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
40 ( 7.75% of base) - ILGEN_0x57cc69ce:Method_0x183df1b1():int
Top method improvements (bytes):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
Top method regressions (percentages):
52 (260.00% of base) - ILGEN_1806854430:main():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
28 (53.85% of base) - ILGEN_0x77e65197:Main():int
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test7():ubyte
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test7():ubyte
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (percentages):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
78 total methods with Code Size differences (1 improved, 77 regressed), 2 unchanged.
Running asm diffs of libraries_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 932
Total bytes of diff: 968
Total bytes of delta: 36 (3.86% of base)
diff is a regression.
Top method regressions (bytes):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
Top method regressions (percentages):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
1 total methods with Code Size differences (0 improved, 1 regressed), 6 unchanged.
Linux ARM
Running asm diffs of coreclr_tests.pmi.Linux.arm.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49502
Total bytes of diff: 52992
Total bytes of delta: 3490 (7.05% of base)
diff is a regression.
Top method regressions (bytes):
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleShort():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleByte():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatShort():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatByte():int
122 (26.18% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (34.96% of base) - ILGEN_622380794:main():int
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
84 (28.77% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
70 ( 0.29% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,int,ushort,double,long,long):int
66 (16.10% of base) - ILGEN_0xe696696:main():int
66 (1,100.00% of base) - ILGEN_1806854430:main():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
66 (12.94% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (1,000.00% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-10 (-11.36% of base) - C:L(float):float
Top method regressions (percentages):
66 (1,100.00% of base) - ILGEN_1806854430:main():int
60 (1,000.00% of base) - ILGEN_622380794:main():int
12 (150.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
44 (146.67% of base) - ILGEN_0xb6f84258:Main():int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
26 (59.09% of base) - ConvTest:test2():short
26 (59.09% of base) - ConvTest:test8():ushort
26 (59.09% of base) - ConvTest:test1():byte
26 (59.09% of base) - ConvTest:test7():ubyte
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
24 (54.55% of base) - ConvTest:test1():byte
24 (54.55% of base) - ConvTest:test2():short
24 (54.55% of base) - ConvTest:test7():ubyte
24 (54.55% of base) - ConvTest:test8():ushort
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
Top method improvements (percentages):
-10 (-11.36% of base) - C:L(float):float
66 total methods with Code Size differences (1 improved, 65 regressed), 1 unchanged.

Which the replays confirm.

Closes#51346.
Closes#47374.

It is not very effective right now because the "bad" combinations of
types are morphed into helpers too early, but it will be helpful when
we enable folding outside of the importer for those cases too.
It now fails on Windows x86, where many of the
previous similar failures were observed.
@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 6, 2021
@SingleAccretionSingleAccretion changed the title Disable folding for implementation-defined castsDisable folding of implementation-defined castsJun 6, 2021
@SingleAccretion
SingleAccretionforce-pushed the Disable-Folding-For-Implementation-Defined-Casts branch from d47687b to d13b563CompareJune 6, 2021 16:51
@SingleAccretion
SingleAccretion marked this pull request as ready for review June 7, 2021 20:19
@tannergooding

Copy link
Copy Markdown
Member

CC. @dotnet/jit-contrib, community PR

@JulieLeeMSFT

Copy link
Copy Markdown
Member

@kunalspathak PTAL for community PR.

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added some questions. Could you share some of the sample diffs that you see in the test (just to understand how this works underlying). Also, did you check asmdiffs on benchmarks/libraries?

Comment threadsrc/coreclr/jit/valuenum.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Also, did you check asmdiffs on benchmarks/libraries?

Yep, the PR's header is for results of running SPMI over all available collections, so, no diffs outside tests.

Could you share some of the sample diffs that you see in the test (just to understand how this works underlying).

Will recollect the diffs and share the samples.

@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Case 1: ILGEN_0x44f8f663:Method_0x2e75f3b4, 76 (133.33% of base):

 G_M64081_IG01:
sub rsp, 40
-+ vzeroupper+
G_M64081_IG02:
movsx rcx, cl
xor ecx, 5
@@ -25,22 +26,41 @@ G_M64081_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, isz
add rcx, rax
mov rax, rcx
shr rax, 32
- jne SHORT G_M64081_IG03+ jne SHORT G_M64081_IG04
xor ecx, ecx
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
- xor ecx, ecx- call CORINFO_HELP_OVERFLOW+ vmovsd xmm0, qword ptr [reloc @RWD00]+ call CORINFO_HELP_DBL2ULNG
; gcr arg pop 0
- int3- ;; bbWeight=1 PerfScore 5.75-G_M64081_IG03: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref+ vxorps xmm0, xmm0+ vcvtsi2ss xmm0, rax+ vcvtss2sd xmm0, xmm0+ call CORINFO_HELP_DBL2ULNG+ ; gcr arg pop 0+ mov rdx, 0xD1FFAB1E+ imul rax, rdx+ mov rdx, 0xD1FFAB1E+ add rax, rdx+ jo SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jg SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jl SHORT G_M64081_IG04+ ;; bbWeight=1 PerfScore 23.83+G_M64081_IG03: ; , epilog, nogc, extend+ add rsp, 40+ ret+ ;; bbWeight=1 PerfScore 1.25+G_M64081_IG04: ; gcVars=0000000000000000 {}, gcrefRegs=00000000 {}, byrefRegs=00000000 {}, gcvars, byref
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
int3
;; bbWeight=0 PerfScore 0.00
+RWD00 dq 4D95800D5C7F3082h ; 5.66058935e+65

Here the early importer folding is blocked, due to the new checks in gtFoldExprConst:

 [ 1] 100 (0x064) nop
[ 1] 101 (0x065) ldc.r8 5.6605893542014790e+65
[ 2] 110 (0x06e) conv.u
-Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- ulong <- double- [000024] ------------ \--* CNS_DBL double 5.6605893542014790e+65-Bashed to long constant:- [000025] ------------ * CNS_INT long 0-
[ 2] 111 (0x06f) conv.r4
-Folding fp operator with constant nodes into a fp constant:- [000026] ------------ * CAST float <- long- [000025] ------------ \--* CNS_INT long 0-Bashed to fp constant:- [000026] ------------ * CNS_DBL float 0.0000000000000000-
[ 2] 112 (0x070) conv.u8
-Folding long operator with constant nodes into a constant:- [000027] ------------ * CAST long <- ulong <- float- [000026] ------------ \--* CNS_DBL float 0.0000000000000000-Bashed to long constant:- [000027] ------------ * CNS_INT long 0-
[ 2] 113 (0x071) mul
[ 1] 114 (0x072) ldc.r4 2281166340096.0000
[ 2] 119 (0x077) ldc.r8 -1.4862075407321284e+46
@@ -475,7 +457,10 @@ STMT00009 (IL ???... ???)
[000095] ---X-------- \--* ADD_ovfl long
[000028] ------------ +--* MUL long
[000018] ------------ | +--* CNS_INT long -0xf925aa1447c2972
- [000027] ------------ | \--* CNS_INT long 0+ [000027] ------------ | \--* CAST long <- ulong <- float+ [000026] ------------ | \--* CAST float <- long+ [000025] ------------ | \--* CAST long <- ulong <- double+ [000024] ------------ | \--* CNS_DBL double 5.6605893542014790e+65
[000094] ---X-------- \--* SUB_ovfl long

Case 2: ILGEN_1806854430:main():int, 42 (700.00% of base):

- mov eax, 100- ;; bbWeight=1 PerfScore 0.25+ vcvttss2si rax, qword ptr [reloc @RWD00]+ cmp rax, 0xD1FFAB1E+ setl dl+ movzx rdx, dl+ movsxd rdx, edx+ cmp rdx, rax+ setg al+ movzx rax, al+ cmp eax, 0xD1FFAB1E+ seta al+ movzx rax, al+ add eax, 100+ ;; bbWeight=1 PerfScore 12.00
G_M58196_IG03: ; , epilog, nogc, extend
ret
;; bbWeight=1 PerfScore 1.00
+RWD00 dd 63E756A3h ; 8.53488e+21

This time, local assertion propagation does not result in gtFoldExprConst folding the expressions in post-order morph:

@@ -518,56 +512,35 @@ Assertion prop in BB01:
Constant Assertion: V00 == 8.53488e+21 index=#01, mask=0000000000000001
[000020] ------------ * CNS_DBL float 8.5348814290707441e+21
-Folding long operator with constant nodes into a constant:- [000021] ------------ * CAST long <- float- [000020] -----+------ \--* CNS_DBL float 8.5348814290707441e+21-Bashed to long constant:- [000021] ------------ * CNS_INT long -0x8000000000000000--Folding operator with constant nodes into a constant:- [000023] ------------ * GT int- [000022] -----+------ +--* CNS_INT long 0x45E23077- [000021] -----+------ \--* CNS_INT long -0x8000000000000000-Bashed to int constant:- [000023] ------------ * CNS_INT int 1--Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- int- [000023] -----+------ \--* CNS_INT int 1-Bashed to long constant:- [000025] ------------ * CNS_INT long 1

Case 3: ConvTest:test1():byte, 16 (44.44% of base):

 G_M30804_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,22 @@ G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- xor ecx, ecx+ vcvttsd2si ecx, dword ptr [reloc @RWD00]+ movsx rsi, cl+ mov ecx, esi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- xor eax, eax- ;; bbWeight=1 PerfScore 4.75+ movsx rax, sil+ ;; bbWeight=1 PerfScore 12.00
G_M30804_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)

Here, VN block takes hold:

 N001 [000002] CNS_DBL -nan(ind) => $140 {DblCns[-nan(ind)]}
VNForCastOper(int) is $41
-N002 [000013] CAST => $42 {IntCns 0x80000000}- VNForCastOper(byte) is $43-N003 [000003] CAST => $44 {IntCns 0}-N004 [000004] LCL_VAR V01 tmp1 d:1 => $44 {IntCns 0}-N005 [000005] ASG => $44 {IntCns 0}+N002 [000013] CAST => $180 {Cast($140, $41)}+ VNForCastOper(byte) is $42+N003 [000003] CAST => $181 {Cast($180, $42)}+N004 [000004] LCL_VAR V01 tmp1 d:1 => $181 {Cast($180, $42)}+N005 [000005] ASG => $181 {Cast($180, $42)}
***** BB01, STMT00001(after)
-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $44-N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $42+N005 ( 10, 12) [000005] -A------R--- * ASG int $181+N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $181+N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $181+N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $180
N001 ( 3, 4) [000002] ------------ \--* CNS_DBL double -nan(ind) $140

This means no constant propagation in assertion prop:

-After constant propagation on [000003]:-STMT00001 (IL 0x00A... ???)-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44- [000016] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N003 ( 1, 3) [000005] -A------R--- * ASG int $44-N002 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N001 ( 1, 1) [000016] ------------ \--* CNS_INT int 0 $44--After constant propagation on [000007]:-STMT00002 (IL ???... ???)-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void- [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44-ReMorphing args for 8.CALL:-argSlots=1, preallocatedArgCount=4, nextSlotNum=4, nextSlotByteOffset=32, outgoingArgSpaceSize=32-ArgTable for 8.CALL after fgMorphArgs:-fgArgTabEntry[arg 0 17.CNS_INT int (By ref), 1 reg: rcx, byteAlignment=8, lateArgInx=0, processed]--optVNAssertionPropCurStmt morphed tree:-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void-N002 ( 1, 1) [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44--After constant propagation on [000015]:-STMT00003 (IL 0x01A... ???)-N003 ( 3, 4) [000009] ------------ * RETURN int $182- [000018] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N002 ( 2, 2) [000009] ------------ * RETURN int $182-N001 ( 1, 1) [000018] ------------ \--* CNS_INT int 0 $44

Case 4: ConvTest:test4():long, -3 (-5.77% of base):

-; Lcl frame size = 40+; Lcl frame size = 32
G_M60593_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,21 @@ G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- mov rcx, 0xD1FFAB1E+ vcvttsd2si rsi, qword ptr [reloc @RWD00]+ mov rcx, rsi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- mov rax, 0xD1FFAB1E- ;; bbWeight=1 PerfScore 4.75+ mov rax, rsi+ ;; bbWeight=1 PerfScore 11.75
G_M60593_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)+-; Total bytes of code 52, prolog size 4, PerfScore 11.45, instruction count 9, allocated bytes for code 52 (MethodHash=1dad134e) for method ConvTest:test4():long+; Total bytes of code 49, prolog size 5, PerfScore 19.65, instruction count 12, allocated bytes for code 49 (MethodHash=1dad134e) for method ConvTest:test4():long

This is another case of no folding in VN:

-N002 [000003] CAST => $180 {LngCns: 0x8000000000000000}-N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {LngCns: 0x8000000000000000}-N004 [000005] ASG => $180 {LngCns: 0x8000000000000000}+N002 [000003] CAST => $180 {Cast($140, $41)}+N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {Cast($140, $41)}+N004 [000005] ASG => $180 {Cast($140, $41)}

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution!

Where they originally were.
@kunalspathak

Copy link
Copy Markdown
Contributor

@SingleAccretion - do you mind taking a look into failures to make sure they are not related to your changes?

@SingleAccretion

SingleAccretion commented Jul 7, 2021

Copy link
Copy Markdown
ContributorAuthor

do you mind taking a look into failures to make sure they are not related to your changes?

@kunalspathak yes of course. Unfortunately the CI is not in the greatest of shapes right now :(.

  1. Build Android x64 Release AllSubsets_Mono_RuntimeTests - log, looks like an infrastructure problem:
[21:26:28] fail: Cannot find a device with app=package:net.dot.JIT_CodeGenBringUpTests, please check that a device is attached
XHarness exit code: 85 (ADB_DEVICE_ENUMERATION_FAILURE)
Test Harness Exitcode is : 85
  1. Build tvOS arm64 Release AllSubsets_Mono - restore failed:
.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : (NETCORE_ENGINEERING_TELEMETRY=Restore) Failed to download package 'Microsoft.Private.Intellisense.5.0.0-preview-20201009.2' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.private.intellisense/5.0.0-preview-20201009.2/microsoft.private.intellisense.5.0.0-preview-20201009.2.nupkg'.
Response status code does not indicate success: 503 (Service Unavailable - TF10216: Azure DevOps services are currently unavailable. Try again later. Activity Id: 84ef9393-5dd8-434a-80b7-f2eb40580efb (DevOps Activity ID: 84EF9393-5DD8-434A-80B7-F2EB40580EFB)).
  1. CoreCLR Product Build OSX arm64 checked - log, another restore failure:
2021-07-06T20:40:41.9426000Z /Users/runner/work/1/s/.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : Failed to download package 'System.Linq.4.1.0-rc2-24027' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/system.linq/4.1.0-rc2-24027/system.linq.4.1.0-rc2-24027.nupkg'. [/Users/runner/work/1/s/src/tests/Common/external/external.csproj] [/Users/runner/work/1/s/src/tests/build.proj]
  1. Libraries Test Run checked coreclr Linux_musl arm Release - log, this time a real test failure:
 Discovering: System.Text.Encoding.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.Text.Encoding.Tests (found 338 of 341 test cases)
Starting: System.Text.Encoding.Tests (parallel test collections = on, max threads = 4)
System.Text.Tests.TranscodingStreamTests.Read_Span(bufferLength: 1) [FAIL]
Assert.Equal() Failure
↓ (pos 4839671)
Expected: ···lmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
Actual: ···lmnopqrstuvwxyzabcdeFghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
↑ (pos 4839671)

This looks like #47444. Seeing as this is a rare failure, maybe we can extract some useful information from this run...?

  1. Libraries Test Run release coreclr Linux x64 Debug - log, another test failure:
System.Net.Http.Functional.Tests.SocketsHttpHandler_HttpClientHandler_ConnectionPooling_Test.Http2_SmallConnectionTimeout_SubsequentRequestUsesDifferentConnection(timeoutPropertyName: "PooledConnectionLifetime") [FAIL]
System.IO.IOException : Unable to write data to the transport connection: Broken pipe.
  1. runtime-dev-innerloop, build #20210706.55, runtime-dev-innerloop, Build OSX x64 release Runtime_Debug, runtime-staging (Build iOSSimulator x64 Release AllSubsets_Mono) - more restore failures.

  2. runtime-staging, many failures - log1, log2, log3 (there are others), not enough space on the device:

Standard Error:
adb: failed to install /datadisks/disk1/work/A1BB08F0/w/B3F70977/e/System.DirectoryServices.Protocols.Tests.apk: Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
  1. runtime-staging, an interpreter test failure - log

  2. runtime-staging, many System.Drawing.Imaging failures (this is Mono on Windows), PNSEs:

 System.Drawing.Imaging.Tests.MetafileTests.Ctor_InvalidEmfTypeIII_ThrowsArgumentException(emfType: 2) [FAIL]
Assert.Throws() Failure
Expected: typeof(System.ArgumentException)
Actual: typeof(System.TypeInitializationException): The type initializer for 'System.Drawing.DrawingCom' threw an exception.
---- System.TypeInitializationException : The type initializer for 'System.Drawing.DrawingCom' threw an exception.

A rich assortment to be sure...

"Real" failures seem to be HTTP one, and the interpreter one, though I find it hard to see how they could be caused by this change (note as well that it passed CI on first run, and no code changes have been committed since).

@kunalspathak
kunalspathak merged commit 527e566 into dotnet:mainJul 7, 2021
@SingleAccretion
SingleAccretion deleted the Disable-Folding-For-Implementation-Defined-Casts branch July 8, 2021 21:21
@ghostghost locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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.

System.Linq.Expressions tests are broken in CI System.Linq.Expressions tests failing on some PRs

4 participants

@SingleAccretion@tannergooding@JulieLeeMSFT@kunalspathak
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Disable folding of implementation-defined casts - #53782

Merged
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts
Jul 7, 2021
Merged

Disable folding of implementation-defined casts#53782
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts

Conversation

@SingleAccretion

@SingleAccretionSingleAccretion commented Jun 6, 2021

Copy link
Copy Markdown
Contributor

With #51440 merged, it is now easy to do the intended second part of that PR and disable folding of all implementation-defined float/double -> integer casts. This is a temporary solution to #47478, but without it I will not be able to move forward with the casts work as a lot of this has so far been masked by the fact that problematic conversions were being morphed into calls and thus not getting folded.

For the diffs, the expectation is that there will be some regressions in coreclr_tests.

Windows x64
Running asm diffs of coreclr_tests.pmi.windows.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49048
Total bytes of diff: 50724
Total bytes of delta: 1676 (3.42% of base)
diff is a regression.
Top method regressions (bytes):
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
95 (30.16% of base) - FloatOvfToInt:TestValuesDoubleInt():int
95 (30.16% of base) - FloatOvfToInt:TestValuesFloatInt():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
59 ( 0.23% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
49 (13.14% of base) - ILGEN_0xe696696:main():int
42 (15.05% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
42 (700.00% of base) - ILGEN_1806854430:main():int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
39 (31.97% of base) - FloatOvfToInt:TestValuesFloatShort():int
38 (19.29% of base) - ILGEN_622380794:main():int
33 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
32 (25.00% of base) - FloatOvfToInt:TestValuesFloatInt():int
32 (25.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (bytes):
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-4 (-5.71% of base) - C:L(float):float
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
Top method regressions (percentages):
42 (700.00% of base) - ILGEN_1806854430:main():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
14 (38.89% of base) - ConvTest:test8():ushort
14 (38.89% of base) - ConvTest:test8():ushort
17 (37.78% of base) - ILGEN_0x64f58bd0:Method_0x1bb0(int,long,float,int,int):int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
Top method improvements (percentages):
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-4 (-5.71% of base) - C:L(float):float
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
67 total methods with Code Size differences (9 improved, 58 regressed), 0 unchanged.
Windows x86
Running asm diffs of coreclr_tests.pmi.windows.x86.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 50715
Total bytes of diff: 52539
Total bytes of delta: 1824 (3.60% of base)
diff is a regression.
Top method regressions (bytes):
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleByte():int
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleShort():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatByte():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatShort():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (23.50% of base) - ILGEN_0xe696696:main():int
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
48 (12.66% of base) - DevDiv_590771:ILGEN_METHOD(long,ushort,int,int,ushort,int):byte
47 ( 8.58% of base) - FloatOvfToInt:TestValuesDoubleInt():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
37 ( 6.75% of base) - FloatOvfToInt:TestValuesFloatInt():int
36 (600.00% of base) - ILGEN_1806854430:main():int
36 (13.90% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
34 ( 5.87% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
32 (12.85% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-8 (-5.23% of base) - C:Main():int
-8 (-7.02% of base) - C:L(float):float
Top method regressions (percentages):
36 (600.00% of base) - ILGEN_1806854430:main():int
24 (400.00% of base) - ILGEN_622380794:main():int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
21 (75.00% of base) - ILGEN_0xb6f84258:Main():int
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test7():ubyte
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test7():ubyte
3 (37.50% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
Top method improvements (percentages):
-8 (-7.02% of base) - C:L(float):float
-8 (-5.23% of base) - C:Main():int
61 total methods with Code Size differences (2 improved, 59 regressed), 0 unchanged.
Linux x64
Running asm diffs of coreclr_tests.pmi.Linux.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 48680
Total bytes of diff: 50694
Total bytes of delta: 2014 (4.14% of base)
diff is a regression.
Top method regressions (bytes):
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
137 (49.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
131 (47.29% of base) - FloatOvfToInt:TestValuesDoubleShort():int
131 (47.29% of base) - FloatOvfToInt:TestValuesFloatShort():int
115 (37.95% of base) - FloatOvfToInt:TestValuesFloatInt():int
115 (37.95% of base) - FloatOvfToInt:TestValuesDoubleInt():int
78 (36.11% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
60 (15.67% of base) - ILGEN_0xe696696:main():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
53 ( 0.22% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
52 (44.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
52 (44.83% of base) - FloatOvfToInt:TestValuesDoubleInt():int
44 (733.33% of base) - ILGEN_1806854430:main():int
42 (16.03% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
38 (16.24% of base) - ILGEN_622380794:main():int
34 (26.77% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
Top method improvements (bytes):
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-8 (-13.11% of base) - C:L(float):float
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
Top method regressions (percentages):
44 (733.33% of base) - ILGEN_1806854430:main():int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test2():short
23 (69.70% of base) - ConvTest:test2():short
22 (66.67% of base) - ConvTest:test7():ubyte
22 (66.67% of base) - ConvTest:test7():ubyte
21 (63.64% of base) - ConvTest:test8():ushort
21 (63.64% of base) - ConvTest:test8():ushort
18 (54.55% of base) - ConvTest:test9():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test9():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
Top method improvements (percentages):
-8 (-13.11% of base) - C:L(float):float
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
65 total methods with Code Size differences (8 improved, 57 regressed), 2 unchanged.
Linux ARM64
Running asm diffs of coreclr_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 51232
Total bytes of diff: 54080
Total bytes of delta: 2848 (5.56% of base)
diff is a regression.
Top method regressions (bytes):
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (35.53% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
64 (12.40% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (18.52% of base) - FloatOvfToInt:TestValuesFloatLong():int
60 (18.52% of base) - FloatOvfToInt:TestValuesDoubleLong():int
60 (14.15% of base) - ILGEN_0xe696696:main():int
52 (260.00% of base) - ILGEN_1806854430:main():int
44 (26.83% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
44 (12.36% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
44 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
40 ( 7.75% of base) - ILGEN_0x57cc69ce:Method_0x183df1b1():int
Top method improvements (bytes):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
Top method regressions (percentages):
52 (260.00% of base) - ILGEN_1806854430:main():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
28 (53.85% of base) - ILGEN_0x77e65197:Main():int
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test7():ubyte
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test7():ubyte
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (percentages):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
78 total methods with Code Size differences (1 improved, 77 regressed), 2 unchanged.
Running asm diffs of libraries_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 932
Total bytes of diff: 968
Total bytes of delta: 36 (3.86% of base)
diff is a regression.
Top method regressions (bytes):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
Top method regressions (percentages):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
1 total methods with Code Size differences (0 improved, 1 regressed), 6 unchanged.
Linux ARM
Running asm diffs of coreclr_tests.pmi.Linux.arm.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49502
Total bytes of diff: 52992
Total bytes of delta: 3490 (7.05% of base)
diff is a regression.
Top method regressions (bytes):
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleShort():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleByte():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatShort():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatByte():int
122 (26.18% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (34.96% of base) - ILGEN_622380794:main():int
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
84 (28.77% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
70 ( 0.29% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,int,ushort,double,long,long):int
66 (16.10% of base) - ILGEN_0xe696696:main():int
66 (1,100.00% of base) - ILGEN_1806854430:main():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
66 (12.94% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (1,000.00% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-10 (-11.36% of base) - C:L(float):float
Top method regressions (percentages):
66 (1,100.00% of base) - ILGEN_1806854430:main():int
60 (1,000.00% of base) - ILGEN_622380794:main():int
12 (150.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
44 (146.67% of base) - ILGEN_0xb6f84258:Main():int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
26 (59.09% of base) - ConvTest:test2():short
26 (59.09% of base) - ConvTest:test8():ushort
26 (59.09% of base) - ConvTest:test1():byte
26 (59.09% of base) - ConvTest:test7():ubyte
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
24 (54.55% of base) - ConvTest:test1():byte
24 (54.55% of base) - ConvTest:test2():short
24 (54.55% of base) - ConvTest:test7():ubyte
24 (54.55% of base) - ConvTest:test8():ushort
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
Top method improvements (percentages):
-10 (-11.36% of base) - C:L(float):float
66 total methods with Code Size differences (1 improved, 65 regressed), 1 unchanged.

Which the replays confirm.

Closes#51346.
Closes#47374.

It is not very effective right now because the "bad" combinations of
types are morphed into helpers too early, but it will be helpful when
we enable folding outside of the importer for those cases too.
It now fails on Windows x86, where many of the
previous similar failures were observed.
@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 6, 2021
@SingleAccretionSingleAccretion changed the title Disable folding for implementation-defined castsDisable folding of implementation-defined castsJun 6, 2021
@SingleAccretion
SingleAccretionforce-pushed the Disable-Folding-For-Implementation-Defined-Casts branch from d47687b to d13b563CompareJune 6, 2021 16:51
@SingleAccretion
SingleAccretion marked this pull request as ready for review June 7, 2021 20:19
@tannergooding

Copy link
Copy Markdown
Member

CC. @dotnet/jit-contrib, community PR

@JulieLeeMSFT

Copy link
Copy Markdown
Member

@kunalspathak PTAL for community PR.

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added some questions. Could you share some of the sample diffs that you see in the test (just to understand how this works underlying). Also, did you check asmdiffs on benchmarks/libraries?

Comment threadsrc/coreclr/jit/valuenum.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Also, did you check asmdiffs on benchmarks/libraries?

Yep, the PR's header is for results of running SPMI over all available collections, so, no diffs outside tests.

Could you share some of the sample diffs that you see in the test (just to understand how this works underlying).

Will recollect the diffs and share the samples.

@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Case 1: ILGEN_0x44f8f663:Method_0x2e75f3b4, 76 (133.33% of base):

 G_M64081_IG01:
sub rsp, 40
-+ vzeroupper+
G_M64081_IG02:
movsx rcx, cl
xor ecx, 5
@@ -25,22 +26,41 @@ G_M64081_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, isz
add rcx, rax
mov rax, rcx
shr rax, 32
- jne SHORT G_M64081_IG03+ jne SHORT G_M64081_IG04
xor ecx, ecx
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
- xor ecx, ecx- call CORINFO_HELP_OVERFLOW+ vmovsd xmm0, qword ptr [reloc @RWD00]+ call CORINFO_HELP_DBL2ULNG
; gcr arg pop 0
- int3- ;; bbWeight=1 PerfScore 5.75-G_M64081_IG03: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref+ vxorps xmm0, xmm0+ vcvtsi2ss xmm0, rax+ vcvtss2sd xmm0, xmm0+ call CORINFO_HELP_DBL2ULNG+ ; gcr arg pop 0+ mov rdx, 0xD1FFAB1E+ imul rax, rdx+ mov rdx, 0xD1FFAB1E+ add rax, rdx+ jo SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jg SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jl SHORT G_M64081_IG04+ ;; bbWeight=1 PerfScore 23.83+G_M64081_IG03: ; , epilog, nogc, extend+ add rsp, 40+ ret+ ;; bbWeight=1 PerfScore 1.25+G_M64081_IG04: ; gcVars=0000000000000000 {}, gcrefRegs=00000000 {}, byrefRegs=00000000 {}, gcvars, byref
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
int3
;; bbWeight=0 PerfScore 0.00
+RWD00 dq 4D95800D5C7F3082h ; 5.66058935e+65

Here the early importer folding is blocked, due to the new checks in gtFoldExprConst:

 [ 1] 100 (0x064) nop
[ 1] 101 (0x065) ldc.r8 5.6605893542014790e+65
[ 2] 110 (0x06e) conv.u
-Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- ulong <- double- [000024] ------------ \--* CNS_DBL double 5.6605893542014790e+65-Bashed to long constant:- [000025] ------------ * CNS_INT long 0-
[ 2] 111 (0x06f) conv.r4
-Folding fp operator with constant nodes into a fp constant:- [000026] ------------ * CAST float <- long- [000025] ------------ \--* CNS_INT long 0-Bashed to fp constant:- [000026] ------------ * CNS_DBL float 0.0000000000000000-
[ 2] 112 (0x070) conv.u8
-Folding long operator with constant nodes into a constant:- [000027] ------------ * CAST long <- ulong <- float- [000026] ------------ \--* CNS_DBL float 0.0000000000000000-Bashed to long constant:- [000027] ------------ * CNS_INT long 0-
[ 2] 113 (0x071) mul
[ 1] 114 (0x072) ldc.r4 2281166340096.0000
[ 2] 119 (0x077) ldc.r8 -1.4862075407321284e+46
@@ -475,7 +457,10 @@ STMT00009 (IL ???... ???)
[000095] ---X-------- \--* ADD_ovfl long
[000028] ------------ +--* MUL long
[000018] ------------ | +--* CNS_INT long -0xf925aa1447c2972
- [000027] ------------ | \--* CNS_INT long 0+ [000027] ------------ | \--* CAST long <- ulong <- float+ [000026] ------------ | \--* CAST float <- long+ [000025] ------------ | \--* CAST long <- ulong <- double+ [000024] ------------ | \--* CNS_DBL double 5.6605893542014790e+65
[000094] ---X-------- \--* SUB_ovfl long

Case 2: ILGEN_1806854430:main():int, 42 (700.00% of base):

- mov eax, 100- ;; bbWeight=1 PerfScore 0.25+ vcvttss2si rax, qword ptr [reloc @RWD00]+ cmp rax, 0xD1FFAB1E+ setl dl+ movzx rdx, dl+ movsxd rdx, edx+ cmp rdx, rax+ setg al+ movzx rax, al+ cmp eax, 0xD1FFAB1E+ seta al+ movzx rax, al+ add eax, 100+ ;; bbWeight=1 PerfScore 12.00
G_M58196_IG03: ; , epilog, nogc, extend
ret
;; bbWeight=1 PerfScore 1.00
+RWD00 dd 63E756A3h ; 8.53488e+21

This time, local assertion propagation does not result in gtFoldExprConst folding the expressions in post-order morph:

@@ -518,56 +512,35 @@ Assertion prop in BB01:
Constant Assertion: V00 == 8.53488e+21 index=#01, mask=0000000000000001
[000020] ------------ * CNS_DBL float 8.5348814290707441e+21
-Folding long operator with constant nodes into a constant:- [000021] ------------ * CAST long <- float- [000020] -----+------ \--* CNS_DBL float 8.5348814290707441e+21-Bashed to long constant:- [000021] ------------ * CNS_INT long -0x8000000000000000--Folding operator with constant nodes into a constant:- [000023] ------------ * GT int- [000022] -----+------ +--* CNS_INT long 0x45E23077- [000021] -----+------ \--* CNS_INT long -0x8000000000000000-Bashed to int constant:- [000023] ------------ * CNS_INT int 1--Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- int- [000023] -----+------ \--* CNS_INT int 1-Bashed to long constant:- [000025] ------------ * CNS_INT long 1

Case 3: ConvTest:test1():byte, 16 (44.44% of base):

 G_M30804_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,22 @@ G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- xor ecx, ecx+ vcvttsd2si ecx, dword ptr [reloc @RWD00]+ movsx rsi, cl+ mov ecx, esi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- xor eax, eax- ;; bbWeight=1 PerfScore 4.75+ movsx rax, sil+ ;; bbWeight=1 PerfScore 12.00
G_M30804_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)

Here, VN block takes hold:

 N001 [000002] CNS_DBL -nan(ind) => $140 {DblCns[-nan(ind)]}
VNForCastOper(int) is $41
-N002 [000013] CAST => $42 {IntCns 0x80000000}- VNForCastOper(byte) is $43-N003 [000003] CAST => $44 {IntCns 0}-N004 [000004] LCL_VAR V01 tmp1 d:1 => $44 {IntCns 0}-N005 [000005] ASG => $44 {IntCns 0}+N002 [000013] CAST => $180 {Cast($140, $41)}+ VNForCastOper(byte) is $42+N003 [000003] CAST => $181 {Cast($180, $42)}+N004 [000004] LCL_VAR V01 tmp1 d:1 => $181 {Cast($180, $42)}+N005 [000005] ASG => $181 {Cast($180, $42)}
***** BB01, STMT00001(after)
-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $44-N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $42+N005 ( 10, 12) [000005] -A------R--- * ASG int $181+N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $181+N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $181+N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $180
N001 ( 3, 4) [000002] ------------ \--* CNS_DBL double -nan(ind) $140

This means no constant propagation in assertion prop:

-After constant propagation on [000003]:-STMT00001 (IL 0x00A... ???)-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44- [000016] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N003 ( 1, 3) [000005] -A------R--- * ASG int $44-N002 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N001 ( 1, 1) [000016] ------------ \--* CNS_INT int 0 $44--After constant propagation on [000007]:-STMT00002 (IL ???... ???)-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void- [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44-ReMorphing args for 8.CALL:-argSlots=1, preallocatedArgCount=4, nextSlotNum=4, nextSlotByteOffset=32, outgoingArgSpaceSize=32-ArgTable for 8.CALL after fgMorphArgs:-fgArgTabEntry[arg 0 17.CNS_INT int (By ref), 1 reg: rcx, byteAlignment=8, lateArgInx=0, processed]--optVNAssertionPropCurStmt morphed tree:-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void-N002 ( 1, 1) [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44--After constant propagation on [000015]:-STMT00003 (IL 0x01A... ???)-N003 ( 3, 4) [000009] ------------ * RETURN int $182- [000018] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N002 ( 2, 2) [000009] ------------ * RETURN int $182-N001 ( 1, 1) [000018] ------------ \--* CNS_INT int 0 $44

Case 4: ConvTest:test4():long, -3 (-5.77% of base):

-; Lcl frame size = 40+; Lcl frame size = 32
G_M60593_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,21 @@ G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- mov rcx, 0xD1FFAB1E+ vcvttsd2si rsi, qword ptr [reloc @RWD00]+ mov rcx, rsi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- mov rax, 0xD1FFAB1E- ;; bbWeight=1 PerfScore 4.75+ mov rax, rsi+ ;; bbWeight=1 PerfScore 11.75
G_M60593_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)+-; Total bytes of code 52, prolog size 4, PerfScore 11.45, instruction count 9, allocated bytes for code 52 (MethodHash=1dad134e) for method ConvTest:test4():long+; Total bytes of code 49, prolog size 5, PerfScore 19.65, instruction count 12, allocated bytes for code 49 (MethodHash=1dad134e) for method ConvTest:test4():long

This is another case of no folding in VN:

-N002 [000003] CAST => $180 {LngCns: 0x8000000000000000}-N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {LngCns: 0x8000000000000000}-N004 [000005] ASG => $180 {LngCns: 0x8000000000000000}+N002 [000003] CAST => $180 {Cast($140, $41)}+N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {Cast($140, $41)}+N004 [000005] ASG => $180 {Cast($140, $41)}

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution!

Where they originally were.
@kunalspathak

Copy link
Copy Markdown
Contributor

@SingleAccretion - do you mind taking a look into failures to make sure they are not related to your changes?

@SingleAccretion

SingleAccretion commented Jul 7, 2021

Copy link
Copy Markdown
ContributorAuthor

do you mind taking a look into failures to make sure they are not related to your changes?

@kunalspathak yes of course. Unfortunately the CI is not in the greatest of shapes right now :(.

  1. Build Android x64 Release AllSubsets_Mono_RuntimeTests - log, looks like an infrastructure problem:
[21:26:28] fail: Cannot find a device with app=package:net.dot.JIT_CodeGenBringUpTests, please check that a device is attached
XHarness exit code: 85 (ADB_DEVICE_ENUMERATION_FAILURE)
Test Harness Exitcode is : 85
  1. Build tvOS arm64 Release AllSubsets_Mono - restore failed:
.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : (NETCORE_ENGINEERING_TELEMETRY=Restore) Failed to download package 'Microsoft.Private.Intellisense.5.0.0-preview-20201009.2' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.private.intellisense/5.0.0-preview-20201009.2/microsoft.private.intellisense.5.0.0-preview-20201009.2.nupkg'.
Response status code does not indicate success: 503 (Service Unavailable - TF10216: Azure DevOps services are currently unavailable. Try again later. Activity Id: 84ef9393-5dd8-434a-80b7-f2eb40580efb (DevOps Activity ID: 84EF9393-5DD8-434A-80B7-F2EB40580EFB)).
  1. CoreCLR Product Build OSX arm64 checked - log, another restore failure:
2021-07-06T20:40:41.9426000Z /Users/runner/work/1/s/.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : Failed to download package 'System.Linq.4.1.0-rc2-24027' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/system.linq/4.1.0-rc2-24027/system.linq.4.1.0-rc2-24027.nupkg'. [/Users/runner/work/1/s/src/tests/Common/external/external.csproj] [/Users/runner/work/1/s/src/tests/build.proj]
  1. Libraries Test Run checked coreclr Linux_musl arm Release - log, this time a real test failure:
 Discovering: System.Text.Encoding.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.Text.Encoding.Tests (found 338 of 341 test cases)
Starting: System.Text.Encoding.Tests (parallel test collections = on, max threads = 4)
System.Text.Tests.TranscodingStreamTests.Read_Span(bufferLength: 1) [FAIL]
Assert.Equal() Failure
↓ (pos 4839671)
Expected: ···lmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
Actual: ···lmnopqrstuvwxyzabcdeFghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
↑ (pos 4839671)

This looks like #47444. Seeing as this is a rare failure, maybe we can extract some useful information from this run...?

  1. Libraries Test Run release coreclr Linux x64 Debug - log, another test failure:
System.Net.Http.Functional.Tests.SocketsHttpHandler_HttpClientHandler_ConnectionPooling_Test.Http2_SmallConnectionTimeout_SubsequentRequestUsesDifferentConnection(timeoutPropertyName: "PooledConnectionLifetime") [FAIL]
System.IO.IOException : Unable to write data to the transport connection: Broken pipe.
  1. runtime-dev-innerloop, build #20210706.55, runtime-dev-innerloop, Build OSX x64 release Runtime_Debug, runtime-staging (Build iOSSimulator x64 Release AllSubsets_Mono) - more restore failures.

  2. runtime-staging, many failures - log1, log2, log3 (there are others), not enough space on the device:

Standard Error:
adb: failed to install /datadisks/disk1/work/A1BB08F0/w/B3F70977/e/System.DirectoryServices.Protocols.Tests.apk: Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
  1. runtime-staging, an interpreter test failure - log

  2. runtime-staging, many System.Drawing.Imaging failures (this is Mono on Windows), PNSEs:

 System.Drawing.Imaging.Tests.MetafileTests.Ctor_InvalidEmfTypeIII_ThrowsArgumentException(emfType: 2) [FAIL]
Assert.Throws() Failure
Expected: typeof(System.ArgumentException)
Actual: typeof(System.TypeInitializationException): The type initializer for 'System.Drawing.DrawingCom' threw an exception.
---- System.TypeInitializationException : The type initializer for 'System.Drawing.DrawingCom' threw an exception.

A rich assortment to be sure...

"Real" failures seem to be HTTP one, and the interpreter one, though I find it hard to see how they could be caused by this change (note as well that it passed CI on first run, and no code changes have been committed since).

@kunalspathak
kunalspathak merged commit 527e566 into dotnet:mainJul 7, 2021
@SingleAccretion
SingleAccretion deleted the Disable-Folding-For-Implementation-Defined-Casts branch July 8, 2021 21:21
@ghostghost locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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.

System.Linq.Expressions tests are broken in CI System.Linq.Expressions tests failing on some PRs

4 participants

@SingleAccretion@tannergooding@JulieLeeMSFT@kunalspathak
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Disable folding of implementation-defined casts - #53782

Merged
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts
Jul 7, 2021
Merged

Disable folding of implementation-defined casts#53782
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts

Conversation

@SingleAccretion

@SingleAccretionSingleAccretion commented Jun 6, 2021

Copy link
Copy Markdown
Contributor

With #51440 merged, it is now easy to do the intended second part of that PR and disable folding of all implementation-defined float/double -> integer casts. This is a temporary solution to #47478, but without it I will not be able to move forward with the casts work as a lot of this has so far been masked by the fact that problematic conversions were being morphed into calls and thus not getting folded.

For the diffs, the expectation is that there will be some regressions in coreclr_tests.

Windows x64
Running asm diffs of coreclr_tests.pmi.windows.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49048
Total bytes of diff: 50724
Total bytes of delta: 1676 (3.42% of base)
diff is a regression.
Top method regressions (bytes):
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
95 (30.16% of base) - FloatOvfToInt:TestValuesDoubleInt():int
95 (30.16% of base) - FloatOvfToInt:TestValuesFloatInt():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
59 ( 0.23% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
49 (13.14% of base) - ILGEN_0xe696696:main():int
42 (15.05% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
42 (700.00% of base) - ILGEN_1806854430:main():int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
39 (31.97% of base) - FloatOvfToInt:TestValuesFloatShort():int
38 (19.29% of base) - ILGEN_622380794:main():int
33 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
32 (25.00% of base) - FloatOvfToInt:TestValuesFloatInt():int
32 (25.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (bytes):
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-4 (-5.71% of base) - C:L(float):float
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
Top method regressions (percentages):
42 (700.00% of base) - ILGEN_1806854430:main():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
14 (38.89% of base) - ConvTest:test8():ushort
14 (38.89% of base) - ConvTest:test8():ushort
17 (37.78% of base) - ILGEN_0x64f58bd0:Method_0x1bb0(int,long,float,int,int):int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
Top method improvements (percentages):
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-4 (-5.71% of base) - C:L(float):float
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
67 total methods with Code Size differences (9 improved, 58 regressed), 0 unchanged.
Windows x86
Running asm diffs of coreclr_tests.pmi.windows.x86.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 50715
Total bytes of diff: 52539
Total bytes of delta: 1824 (3.60% of base)
diff is a regression.
Top method regressions (bytes):
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleByte():int
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleShort():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatByte():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatShort():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (23.50% of base) - ILGEN_0xe696696:main():int
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
48 (12.66% of base) - DevDiv_590771:ILGEN_METHOD(long,ushort,int,int,ushort,int):byte
47 ( 8.58% of base) - FloatOvfToInt:TestValuesDoubleInt():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
37 ( 6.75% of base) - FloatOvfToInt:TestValuesFloatInt():int
36 (600.00% of base) - ILGEN_1806854430:main():int
36 (13.90% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
34 ( 5.87% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
32 (12.85% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-8 (-5.23% of base) - C:Main():int
-8 (-7.02% of base) - C:L(float):float
Top method regressions (percentages):
36 (600.00% of base) - ILGEN_1806854430:main():int
24 (400.00% of base) - ILGEN_622380794:main():int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
21 (75.00% of base) - ILGEN_0xb6f84258:Main():int
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test7():ubyte
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test7():ubyte
3 (37.50% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
Top method improvements (percentages):
-8 (-7.02% of base) - C:L(float):float
-8 (-5.23% of base) - C:Main():int
61 total methods with Code Size differences (2 improved, 59 regressed), 0 unchanged.
Linux x64
Running asm diffs of coreclr_tests.pmi.Linux.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 48680
Total bytes of diff: 50694
Total bytes of delta: 2014 (4.14% of base)
diff is a regression.
Top method regressions (bytes):
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
137 (49.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
131 (47.29% of base) - FloatOvfToInt:TestValuesDoubleShort():int
131 (47.29% of base) - FloatOvfToInt:TestValuesFloatShort():int
115 (37.95% of base) - FloatOvfToInt:TestValuesFloatInt():int
115 (37.95% of base) - FloatOvfToInt:TestValuesDoubleInt():int
78 (36.11% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
60 (15.67% of base) - ILGEN_0xe696696:main():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
53 ( 0.22% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
52 (44.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
52 (44.83% of base) - FloatOvfToInt:TestValuesDoubleInt():int
44 (733.33% of base) - ILGEN_1806854430:main():int
42 (16.03% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
38 (16.24% of base) - ILGEN_622380794:main():int
34 (26.77% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
Top method improvements (bytes):
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-8 (-13.11% of base) - C:L(float):float
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
Top method regressions (percentages):
44 (733.33% of base) - ILGEN_1806854430:main():int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test2():short
23 (69.70% of base) - ConvTest:test2():short
22 (66.67% of base) - ConvTest:test7():ubyte
22 (66.67% of base) - ConvTest:test7():ubyte
21 (63.64% of base) - ConvTest:test8():ushort
21 (63.64% of base) - ConvTest:test8():ushort
18 (54.55% of base) - ConvTest:test9():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test9():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
Top method improvements (percentages):
-8 (-13.11% of base) - C:L(float):float
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
65 total methods with Code Size differences (8 improved, 57 regressed), 2 unchanged.
Linux ARM64
Running asm diffs of coreclr_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 51232
Total bytes of diff: 54080
Total bytes of delta: 2848 (5.56% of base)
diff is a regression.
Top method regressions (bytes):
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (35.53% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
64 (12.40% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (18.52% of base) - FloatOvfToInt:TestValuesFloatLong():int
60 (18.52% of base) - FloatOvfToInt:TestValuesDoubleLong():int
60 (14.15% of base) - ILGEN_0xe696696:main():int
52 (260.00% of base) - ILGEN_1806854430:main():int
44 (26.83% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
44 (12.36% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
44 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
40 ( 7.75% of base) - ILGEN_0x57cc69ce:Method_0x183df1b1():int
Top method improvements (bytes):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
Top method regressions (percentages):
52 (260.00% of base) - ILGEN_1806854430:main():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
28 (53.85% of base) - ILGEN_0x77e65197:Main():int
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test7():ubyte
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test7():ubyte
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (percentages):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
78 total methods with Code Size differences (1 improved, 77 regressed), 2 unchanged.
Running asm diffs of libraries_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 932
Total bytes of diff: 968
Total bytes of delta: 36 (3.86% of base)
diff is a regression.
Top method regressions (bytes):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
Top method regressions (percentages):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
1 total methods with Code Size differences (0 improved, 1 regressed), 6 unchanged.
Linux ARM
Running asm diffs of coreclr_tests.pmi.Linux.arm.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49502
Total bytes of diff: 52992
Total bytes of delta: 3490 (7.05% of base)
diff is a regression.
Top method regressions (bytes):
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleShort():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleByte():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatShort():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatByte():int
122 (26.18% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (34.96% of base) - ILGEN_622380794:main():int
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
84 (28.77% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
70 ( 0.29% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,int,ushort,double,long,long):int
66 (16.10% of base) - ILGEN_0xe696696:main():int
66 (1,100.00% of base) - ILGEN_1806854430:main():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
66 (12.94% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (1,000.00% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-10 (-11.36% of base) - C:L(float):float
Top method regressions (percentages):
66 (1,100.00% of base) - ILGEN_1806854430:main():int
60 (1,000.00% of base) - ILGEN_622380794:main():int
12 (150.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
44 (146.67% of base) - ILGEN_0xb6f84258:Main():int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
26 (59.09% of base) - ConvTest:test2():short
26 (59.09% of base) - ConvTest:test8():ushort
26 (59.09% of base) - ConvTest:test1():byte
26 (59.09% of base) - ConvTest:test7():ubyte
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
24 (54.55% of base) - ConvTest:test1():byte
24 (54.55% of base) - ConvTest:test2():short
24 (54.55% of base) - ConvTest:test7():ubyte
24 (54.55% of base) - ConvTest:test8():ushort
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
Top method improvements (percentages):
-10 (-11.36% of base) - C:L(float):float
66 total methods with Code Size differences (1 improved, 65 regressed), 1 unchanged.

Which the replays confirm.

Closes#51346.
Closes#47374.

It is not very effective right now because the "bad" combinations of
types are morphed into helpers too early, but it will be helpful when
we enable folding outside of the importer for those cases too.
It now fails on Windows x86, where many of the
previous similar failures were observed.
@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 6, 2021
@SingleAccretionSingleAccretion changed the title Disable folding for implementation-defined castsDisable folding of implementation-defined castsJun 6, 2021
@SingleAccretion
SingleAccretionforce-pushed the Disable-Folding-For-Implementation-Defined-Casts branch from d47687b to d13b563CompareJune 6, 2021 16:51
@SingleAccretion
SingleAccretion marked this pull request as ready for review June 7, 2021 20:19
@tannergooding

Copy link
Copy Markdown
Member

CC. @dotnet/jit-contrib, community PR

@JulieLeeMSFT

Copy link
Copy Markdown
Member

@kunalspathak PTAL for community PR.

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added some questions. Could you share some of the sample diffs that you see in the test (just to understand how this works underlying). Also, did you check asmdiffs on benchmarks/libraries?

Comment threadsrc/coreclr/jit/valuenum.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Also, did you check asmdiffs on benchmarks/libraries?

Yep, the PR's header is for results of running SPMI over all available collections, so, no diffs outside tests.

Could you share some of the sample diffs that you see in the test (just to understand how this works underlying).

Will recollect the diffs and share the samples.

@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Case 1: ILGEN_0x44f8f663:Method_0x2e75f3b4, 76 (133.33% of base):

 G_M64081_IG01:
sub rsp, 40
-+ vzeroupper+
G_M64081_IG02:
movsx rcx, cl
xor ecx, 5
@@ -25,22 +26,41 @@ G_M64081_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, isz
add rcx, rax
mov rax, rcx
shr rax, 32
- jne SHORT G_M64081_IG03+ jne SHORT G_M64081_IG04
xor ecx, ecx
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
- xor ecx, ecx- call CORINFO_HELP_OVERFLOW+ vmovsd xmm0, qword ptr [reloc @RWD00]+ call CORINFO_HELP_DBL2ULNG
; gcr arg pop 0
- int3- ;; bbWeight=1 PerfScore 5.75-G_M64081_IG03: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref+ vxorps xmm0, xmm0+ vcvtsi2ss xmm0, rax+ vcvtss2sd xmm0, xmm0+ call CORINFO_HELP_DBL2ULNG+ ; gcr arg pop 0+ mov rdx, 0xD1FFAB1E+ imul rax, rdx+ mov rdx, 0xD1FFAB1E+ add rax, rdx+ jo SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jg SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jl SHORT G_M64081_IG04+ ;; bbWeight=1 PerfScore 23.83+G_M64081_IG03: ; , epilog, nogc, extend+ add rsp, 40+ ret+ ;; bbWeight=1 PerfScore 1.25+G_M64081_IG04: ; gcVars=0000000000000000 {}, gcrefRegs=00000000 {}, byrefRegs=00000000 {}, gcvars, byref
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
int3
;; bbWeight=0 PerfScore 0.00
+RWD00 dq 4D95800D5C7F3082h ; 5.66058935e+65

Here the early importer folding is blocked, due to the new checks in gtFoldExprConst:

 [ 1] 100 (0x064) nop
[ 1] 101 (0x065) ldc.r8 5.6605893542014790e+65
[ 2] 110 (0x06e) conv.u
-Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- ulong <- double- [000024] ------------ \--* CNS_DBL double 5.6605893542014790e+65-Bashed to long constant:- [000025] ------------ * CNS_INT long 0-
[ 2] 111 (0x06f) conv.r4
-Folding fp operator with constant nodes into a fp constant:- [000026] ------------ * CAST float <- long- [000025] ------------ \--* CNS_INT long 0-Bashed to fp constant:- [000026] ------------ * CNS_DBL float 0.0000000000000000-
[ 2] 112 (0x070) conv.u8
-Folding long operator with constant nodes into a constant:- [000027] ------------ * CAST long <- ulong <- float- [000026] ------------ \--* CNS_DBL float 0.0000000000000000-Bashed to long constant:- [000027] ------------ * CNS_INT long 0-
[ 2] 113 (0x071) mul
[ 1] 114 (0x072) ldc.r4 2281166340096.0000
[ 2] 119 (0x077) ldc.r8 -1.4862075407321284e+46
@@ -475,7 +457,10 @@ STMT00009 (IL ???... ???)
[000095] ---X-------- \--* ADD_ovfl long
[000028] ------------ +--* MUL long
[000018] ------------ | +--* CNS_INT long -0xf925aa1447c2972
- [000027] ------------ | \--* CNS_INT long 0+ [000027] ------------ | \--* CAST long <- ulong <- float+ [000026] ------------ | \--* CAST float <- long+ [000025] ------------ | \--* CAST long <- ulong <- double+ [000024] ------------ | \--* CNS_DBL double 5.6605893542014790e+65
[000094] ---X-------- \--* SUB_ovfl long

Case 2: ILGEN_1806854430:main():int, 42 (700.00% of base):

- mov eax, 100- ;; bbWeight=1 PerfScore 0.25+ vcvttss2si rax, qword ptr [reloc @RWD00]+ cmp rax, 0xD1FFAB1E+ setl dl+ movzx rdx, dl+ movsxd rdx, edx+ cmp rdx, rax+ setg al+ movzx rax, al+ cmp eax, 0xD1FFAB1E+ seta al+ movzx rax, al+ add eax, 100+ ;; bbWeight=1 PerfScore 12.00
G_M58196_IG03: ; , epilog, nogc, extend
ret
;; bbWeight=1 PerfScore 1.00
+RWD00 dd 63E756A3h ; 8.53488e+21

This time, local assertion propagation does not result in gtFoldExprConst folding the expressions in post-order morph:

@@ -518,56 +512,35 @@ Assertion prop in BB01:
Constant Assertion: V00 == 8.53488e+21 index=#01, mask=0000000000000001
[000020] ------------ * CNS_DBL float 8.5348814290707441e+21
-Folding long operator with constant nodes into a constant:- [000021] ------------ * CAST long <- float- [000020] -----+------ \--* CNS_DBL float 8.5348814290707441e+21-Bashed to long constant:- [000021] ------------ * CNS_INT long -0x8000000000000000--Folding operator with constant nodes into a constant:- [000023] ------------ * GT int- [000022] -----+------ +--* CNS_INT long 0x45E23077- [000021] -----+------ \--* CNS_INT long -0x8000000000000000-Bashed to int constant:- [000023] ------------ * CNS_INT int 1--Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- int- [000023] -----+------ \--* CNS_INT int 1-Bashed to long constant:- [000025] ------------ * CNS_INT long 1

Case 3: ConvTest:test1():byte, 16 (44.44% of base):

 G_M30804_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,22 @@ G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- xor ecx, ecx+ vcvttsd2si ecx, dword ptr [reloc @RWD00]+ movsx rsi, cl+ mov ecx, esi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- xor eax, eax- ;; bbWeight=1 PerfScore 4.75+ movsx rax, sil+ ;; bbWeight=1 PerfScore 12.00
G_M30804_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)

Here, VN block takes hold:

 N001 [000002] CNS_DBL -nan(ind) => $140 {DblCns[-nan(ind)]}
VNForCastOper(int) is $41
-N002 [000013] CAST => $42 {IntCns 0x80000000}- VNForCastOper(byte) is $43-N003 [000003] CAST => $44 {IntCns 0}-N004 [000004] LCL_VAR V01 tmp1 d:1 => $44 {IntCns 0}-N005 [000005] ASG => $44 {IntCns 0}+N002 [000013] CAST => $180 {Cast($140, $41)}+ VNForCastOper(byte) is $42+N003 [000003] CAST => $181 {Cast($180, $42)}+N004 [000004] LCL_VAR V01 tmp1 d:1 => $181 {Cast($180, $42)}+N005 [000005] ASG => $181 {Cast($180, $42)}
***** BB01, STMT00001(after)
-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $44-N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $42+N005 ( 10, 12) [000005] -A------R--- * ASG int $181+N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $181+N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $181+N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $180
N001 ( 3, 4) [000002] ------------ \--* CNS_DBL double -nan(ind) $140

This means no constant propagation in assertion prop:

-After constant propagation on [000003]:-STMT00001 (IL 0x00A... ???)-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44- [000016] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N003 ( 1, 3) [000005] -A------R--- * ASG int $44-N002 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N001 ( 1, 1) [000016] ------------ \--* CNS_INT int 0 $44--After constant propagation on [000007]:-STMT00002 (IL ???... ???)-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void- [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44-ReMorphing args for 8.CALL:-argSlots=1, preallocatedArgCount=4, nextSlotNum=4, nextSlotByteOffset=32, outgoingArgSpaceSize=32-ArgTable for 8.CALL after fgMorphArgs:-fgArgTabEntry[arg 0 17.CNS_INT int (By ref), 1 reg: rcx, byteAlignment=8, lateArgInx=0, processed]--optVNAssertionPropCurStmt morphed tree:-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void-N002 ( 1, 1) [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44--After constant propagation on [000015]:-STMT00003 (IL 0x01A... ???)-N003 ( 3, 4) [000009] ------------ * RETURN int $182- [000018] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N002 ( 2, 2) [000009] ------------ * RETURN int $182-N001 ( 1, 1) [000018] ------------ \--* CNS_INT int 0 $44

Case 4: ConvTest:test4():long, -3 (-5.77% of base):

-; Lcl frame size = 40+; Lcl frame size = 32
G_M60593_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,21 @@ G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- mov rcx, 0xD1FFAB1E+ vcvttsd2si rsi, qword ptr [reloc @RWD00]+ mov rcx, rsi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- mov rax, 0xD1FFAB1E- ;; bbWeight=1 PerfScore 4.75+ mov rax, rsi+ ;; bbWeight=1 PerfScore 11.75
G_M60593_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)+-; Total bytes of code 52, prolog size 4, PerfScore 11.45, instruction count 9, allocated bytes for code 52 (MethodHash=1dad134e) for method ConvTest:test4():long+; Total bytes of code 49, prolog size 5, PerfScore 19.65, instruction count 12, allocated bytes for code 49 (MethodHash=1dad134e) for method ConvTest:test4():long

This is another case of no folding in VN:

-N002 [000003] CAST => $180 {LngCns: 0x8000000000000000}-N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {LngCns: 0x8000000000000000}-N004 [000005] ASG => $180 {LngCns: 0x8000000000000000}+N002 [000003] CAST => $180 {Cast($140, $41)}+N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {Cast($140, $41)}+N004 [000005] ASG => $180 {Cast($140, $41)}

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution!

Where they originally were.
@kunalspathak

Copy link
Copy Markdown
Contributor

@SingleAccretion - do you mind taking a look into failures to make sure they are not related to your changes?

@SingleAccretion

SingleAccretion commented Jul 7, 2021

Copy link
Copy Markdown
ContributorAuthor

do you mind taking a look into failures to make sure they are not related to your changes?

@kunalspathak yes of course. Unfortunately the CI is not in the greatest of shapes right now :(.

  1. Build Android x64 Release AllSubsets_Mono_RuntimeTests - log, looks like an infrastructure problem:
[21:26:28] fail: Cannot find a device with app=package:net.dot.JIT_CodeGenBringUpTests, please check that a device is attached
XHarness exit code: 85 (ADB_DEVICE_ENUMERATION_FAILURE)
Test Harness Exitcode is : 85
  1. Build tvOS arm64 Release AllSubsets_Mono - restore failed:
.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : (NETCORE_ENGINEERING_TELEMETRY=Restore) Failed to download package 'Microsoft.Private.Intellisense.5.0.0-preview-20201009.2' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.private.intellisense/5.0.0-preview-20201009.2/microsoft.private.intellisense.5.0.0-preview-20201009.2.nupkg'.
Response status code does not indicate success: 503 (Service Unavailable - TF10216: Azure DevOps services are currently unavailable. Try again later. Activity Id: 84ef9393-5dd8-434a-80b7-f2eb40580efb (DevOps Activity ID: 84EF9393-5DD8-434A-80B7-F2EB40580EFB)).
  1. CoreCLR Product Build OSX arm64 checked - log, another restore failure:
2021-07-06T20:40:41.9426000Z /Users/runner/work/1/s/.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : Failed to download package 'System.Linq.4.1.0-rc2-24027' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/system.linq/4.1.0-rc2-24027/system.linq.4.1.0-rc2-24027.nupkg'. [/Users/runner/work/1/s/src/tests/Common/external/external.csproj] [/Users/runner/work/1/s/src/tests/build.proj]
  1. Libraries Test Run checked coreclr Linux_musl arm Release - log, this time a real test failure:
 Discovering: System.Text.Encoding.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.Text.Encoding.Tests (found 338 of 341 test cases)
Starting: System.Text.Encoding.Tests (parallel test collections = on, max threads = 4)
System.Text.Tests.TranscodingStreamTests.Read_Span(bufferLength: 1) [FAIL]
Assert.Equal() Failure
↓ (pos 4839671)
Expected: ···lmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
Actual: ···lmnopqrstuvwxyzabcdeFghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
↑ (pos 4839671)

This looks like #47444. Seeing as this is a rare failure, maybe we can extract some useful information from this run...?

  1. Libraries Test Run release coreclr Linux x64 Debug - log, another test failure:
System.Net.Http.Functional.Tests.SocketsHttpHandler_HttpClientHandler_ConnectionPooling_Test.Http2_SmallConnectionTimeout_SubsequentRequestUsesDifferentConnection(timeoutPropertyName: "PooledConnectionLifetime") [FAIL]
System.IO.IOException : Unable to write data to the transport connection: Broken pipe.
  1. runtime-dev-innerloop, build #20210706.55, runtime-dev-innerloop, Build OSX x64 release Runtime_Debug, runtime-staging (Build iOSSimulator x64 Release AllSubsets_Mono) - more restore failures.

  2. runtime-staging, many failures - log1, log2, log3 (there are others), not enough space on the device:

Standard Error:
adb: failed to install /datadisks/disk1/work/A1BB08F0/w/B3F70977/e/System.DirectoryServices.Protocols.Tests.apk: Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
  1. runtime-staging, an interpreter test failure - log

  2. runtime-staging, many System.Drawing.Imaging failures (this is Mono on Windows), PNSEs:

 System.Drawing.Imaging.Tests.MetafileTests.Ctor_InvalidEmfTypeIII_ThrowsArgumentException(emfType: 2) [FAIL]
Assert.Throws() Failure
Expected: typeof(System.ArgumentException)
Actual: typeof(System.TypeInitializationException): The type initializer for 'System.Drawing.DrawingCom' threw an exception.
---- System.TypeInitializationException : The type initializer for 'System.Drawing.DrawingCom' threw an exception.

A rich assortment to be sure...

"Real" failures seem to be HTTP one, and the interpreter one, though I find it hard to see how they could be caused by this change (note as well that it passed CI on first run, and no code changes have been committed since).

@kunalspathak
kunalspathak merged commit 527e566 into dotnet:mainJul 7, 2021
@SingleAccretion
SingleAccretion deleted the Disable-Folding-For-Implementation-Defined-Casts branch July 8, 2021 21:21
@ghostghost locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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.

System.Linq.Expressions tests are broken in CI System.Linq.Expressions tests failing on some PRs

4 participants

@SingleAccretion@tannergooding@JulieLeeMSFT@kunalspathak
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Disable folding of implementation-defined casts - #53782

Merged
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts
Jul 7, 2021
Merged

Disable folding of implementation-defined casts#53782
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts

Conversation

@SingleAccretion

@SingleAccretionSingleAccretion commented Jun 6, 2021

Copy link
Copy Markdown
Contributor

With #51440 merged, it is now easy to do the intended second part of that PR and disable folding of all implementation-defined float/double -> integer casts. This is a temporary solution to #47478, but without it I will not be able to move forward with the casts work as a lot of this has so far been masked by the fact that problematic conversions were being morphed into calls and thus not getting folded.

For the diffs, the expectation is that there will be some regressions in coreclr_tests.

Windows x64
Running asm diffs of coreclr_tests.pmi.windows.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49048
Total bytes of diff: 50724
Total bytes of delta: 1676 (3.42% of base)
diff is a regression.
Top method regressions (bytes):
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
95 (30.16% of base) - FloatOvfToInt:TestValuesDoubleInt():int
95 (30.16% of base) - FloatOvfToInt:TestValuesFloatInt():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
59 ( 0.23% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
49 (13.14% of base) - ILGEN_0xe696696:main():int
42 (15.05% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
42 (700.00% of base) - ILGEN_1806854430:main():int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
39 (31.97% of base) - FloatOvfToInt:TestValuesFloatShort():int
38 (19.29% of base) - ILGEN_622380794:main():int
33 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
32 (25.00% of base) - FloatOvfToInt:TestValuesFloatInt():int
32 (25.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (bytes):
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-4 (-5.71% of base) - C:L(float):float
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
Top method regressions (percentages):
42 (700.00% of base) - ILGEN_1806854430:main():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
14 (38.89% of base) - ConvTest:test8():ushort
14 (38.89% of base) - ConvTest:test8():ushort
17 (37.78% of base) - ILGEN_0x64f58bd0:Method_0x1bb0(int,long,float,int,int):int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
Top method improvements (percentages):
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-4 (-5.71% of base) - C:L(float):float
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
67 total methods with Code Size differences (9 improved, 58 regressed), 0 unchanged.
Windows x86
Running asm diffs of coreclr_tests.pmi.windows.x86.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 50715
Total bytes of diff: 52539
Total bytes of delta: 1824 (3.60% of base)
diff is a regression.
Top method regressions (bytes):
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleByte():int
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleShort():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatByte():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatShort():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (23.50% of base) - ILGEN_0xe696696:main():int
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
48 (12.66% of base) - DevDiv_590771:ILGEN_METHOD(long,ushort,int,int,ushort,int):byte
47 ( 8.58% of base) - FloatOvfToInt:TestValuesDoubleInt():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
37 ( 6.75% of base) - FloatOvfToInt:TestValuesFloatInt():int
36 (600.00% of base) - ILGEN_1806854430:main():int
36 (13.90% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
34 ( 5.87% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
32 (12.85% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-8 (-5.23% of base) - C:Main():int
-8 (-7.02% of base) - C:L(float):float
Top method regressions (percentages):
36 (600.00% of base) - ILGEN_1806854430:main():int
24 (400.00% of base) - ILGEN_622380794:main():int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
21 (75.00% of base) - ILGEN_0xb6f84258:Main():int
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test7():ubyte
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test7():ubyte
3 (37.50% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
Top method improvements (percentages):
-8 (-7.02% of base) - C:L(float):float
-8 (-5.23% of base) - C:Main():int
61 total methods with Code Size differences (2 improved, 59 regressed), 0 unchanged.
Linux x64
Running asm diffs of coreclr_tests.pmi.Linux.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 48680
Total bytes of diff: 50694
Total bytes of delta: 2014 (4.14% of base)
diff is a regression.
Top method regressions (bytes):
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
137 (49.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
131 (47.29% of base) - FloatOvfToInt:TestValuesDoubleShort():int
131 (47.29% of base) - FloatOvfToInt:TestValuesFloatShort():int
115 (37.95% of base) - FloatOvfToInt:TestValuesFloatInt():int
115 (37.95% of base) - FloatOvfToInt:TestValuesDoubleInt():int
78 (36.11% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
60 (15.67% of base) - ILGEN_0xe696696:main():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
53 ( 0.22% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
52 (44.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
52 (44.83% of base) - FloatOvfToInt:TestValuesDoubleInt():int
44 (733.33% of base) - ILGEN_1806854430:main():int
42 (16.03% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
38 (16.24% of base) - ILGEN_622380794:main():int
34 (26.77% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
Top method improvements (bytes):
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-8 (-13.11% of base) - C:L(float):float
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
Top method regressions (percentages):
44 (733.33% of base) - ILGEN_1806854430:main():int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test2():short
23 (69.70% of base) - ConvTest:test2():short
22 (66.67% of base) - ConvTest:test7():ubyte
22 (66.67% of base) - ConvTest:test7():ubyte
21 (63.64% of base) - ConvTest:test8():ushort
21 (63.64% of base) - ConvTest:test8():ushort
18 (54.55% of base) - ConvTest:test9():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test9():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
Top method improvements (percentages):
-8 (-13.11% of base) - C:L(float):float
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
65 total methods with Code Size differences (8 improved, 57 regressed), 2 unchanged.
Linux ARM64
Running asm diffs of coreclr_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 51232
Total bytes of diff: 54080
Total bytes of delta: 2848 (5.56% of base)
diff is a regression.
Top method regressions (bytes):
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (35.53% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
64 (12.40% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (18.52% of base) - FloatOvfToInt:TestValuesFloatLong():int
60 (18.52% of base) - FloatOvfToInt:TestValuesDoubleLong():int
60 (14.15% of base) - ILGEN_0xe696696:main():int
52 (260.00% of base) - ILGEN_1806854430:main():int
44 (26.83% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
44 (12.36% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
44 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
40 ( 7.75% of base) - ILGEN_0x57cc69ce:Method_0x183df1b1():int
Top method improvements (bytes):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
Top method regressions (percentages):
52 (260.00% of base) - ILGEN_1806854430:main():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
28 (53.85% of base) - ILGEN_0x77e65197:Main():int
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test7():ubyte
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test7():ubyte
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (percentages):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
78 total methods with Code Size differences (1 improved, 77 regressed), 2 unchanged.
Running asm diffs of libraries_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 932
Total bytes of diff: 968
Total bytes of delta: 36 (3.86% of base)
diff is a regression.
Top method regressions (bytes):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
Top method regressions (percentages):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
1 total methods with Code Size differences (0 improved, 1 regressed), 6 unchanged.
Linux ARM
Running asm diffs of coreclr_tests.pmi.Linux.arm.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49502
Total bytes of diff: 52992
Total bytes of delta: 3490 (7.05% of base)
diff is a regression.
Top method regressions (bytes):
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleShort():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleByte():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatShort():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatByte():int
122 (26.18% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (34.96% of base) - ILGEN_622380794:main():int
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
84 (28.77% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
70 ( 0.29% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,int,ushort,double,long,long):int
66 (16.10% of base) - ILGEN_0xe696696:main():int
66 (1,100.00% of base) - ILGEN_1806854430:main():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
66 (12.94% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (1,000.00% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-10 (-11.36% of base) - C:L(float):float
Top method regressions (percentages):
66 (1,100.00% of base) - ILGEN_1806854430:main():int
60 (1,000.00% of base) - ILGEN_622380794:main():int
12 (150.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
44 (146.67% of base) - ILGEN_0xb6f84258:Main():int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
26 (59.09% of base) - ConvTest:test2():short
26 (59.09% of base) - ConvTest:test8():ushort
26 (59.09% of base) - ConvTest:test1():byte
26 (59.09% of base) - ConvTest:test7():ubyte
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
24 (54.55% of base) - ConvTest:test1():byte
24 (54.55% of base) - ConvTest:test2():short
24 (54.55% of base) - ConvTest:test7():ubyte
24 (54.55% of base) - ConvTest:test8():ushort
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
Top method improvements (percentages):
-10 (-11.36% of base) - C:L(float):float
66 total methods with Code Size differences (1 improved, 65 regressed), 1 unchanged.

Which the replays confirm.

Closes#51346.
Closes#47374.

It is not very effective right now because the "bad" combinations of
types are morphed into helpers too early, but it will be helpful when
we enable folding outside of the importer for those cases too.
It now fails on Windows x86, where many of the
previous similar failures were observed.
@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 6, 2021
@SingleAccretionSingleAccretion changed the title Disable folding for implementation-defined castsDisable folding of implementation-defined castsJun 6, 2021
@SingleAccretion
SingleAccretionforce-pushed the Disable-Folding-For-Implementation-Defined-Casts branch from d47687b to d13b563CompareJune 6, 2021 16:51
@SingleAccretion
SingleAccretion marked this pull request as ready for review June 7, 2021 20:19
@tannergooding

Copy link
Copy Markdown
Member

CC. @dotnet/jit-contrib, community PR

@JulieLeeMSFT

Copy link
Copy Markdown
Member

@kunalspathak PTAL for community PR.

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added some questions. Could you share some of the sample diffs that you see in the test (just to understand how this works underlying). Also, did you check asmdiffs on benchmarks/libraries?

Comment threadsrc/coreclr/jit/valuenum.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Also, did you check asmdiffs on benchmarks/libraries?

Yep, the PR's header is for results of running SPMI over all available collections, so, no diffs outside tests.

Could you share some of the sample diffs that you see in the test (just to understand how this works underlying).

Will recollect the diffs and share the samples.

@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Case 1: ILGEN_0x44f8f663:Method_0x2e75f3b4, 76 (133.33% of base):

 G_M64081_IG01:
sub rsp, 40
-+ vzeroupper+
G_M64081_IG02:
movsx rcx, cl
xor ecx, 5
@@ -25,22 +26,41 @@ G_M64081_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, isz
add rcx, rax
mov rax, rcx
shr rax, 32
- jne SHORT G_M64081_IG03+ jne SHORT G_M64081_IG04
xor ecx, ecx
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
- xor ecx, ecx- call CORINFO_HELP_OVERFLOW+ vmovsd xmm0, qword ptr [reloc @RWD00]+ call CORINFO_HELP_DBL2ULNG
; gcr arg pop 0
- int3- ;; bbWeight=1 PerfScore 5.75-G_M64081_IG03: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref+ vxorps xmm0, xmm0+ vcvtsi2ss xmm0, rax+ vcvtss2sd xmm0, xmm0+ call CORINFO_HELP_DBL2ULNG+ ; gcr arg pop 0+ mov rdx, 0xD1FFAB1E+ imul rax, rdx+ mov rdx, 0xD1FFAB1E+ add rax, rdx+ jo SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jg SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jl SHORT G_M64081_IG04+ ;; bbWeight=1 PerfScore 23.83+G_M64081_IG03: ; , epilog, nogc, extend+ add rsp, 40+ ret+ ;; bbWeight=1 PerfScore 1.25+G_M64081_IG04: ; gcVars=0000000000000000 {}, gcrefRegs=00000000 {}, byrefRegs=00000000 {}, gcvars, byref
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
int3
;; bbWeight=0 PerfScore 0.00
+RWD00 dq 4D95800D5C7F3082h ; 5.66058935e+65

Here the early importer folding is blocked, due to the new checks in gtFoldExprConst:

 [ 1] 100 (0x064) nop
[ 1] 101 (0x065) ldc.r8 5.6605893542014790e+65
[ 2] 110 (0x06e) conv.u
-Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- ulong <- double- [000024] ------------ \--* CNS_DBL double 5.6605893542014790e+65-Bashed to long constant:- [000025] ------------ * CNS_INT long 0-
[ 2] 111 (0x06f) conv.r4
-Folding fp operator with constant nodes into a fp constant:- [000026] ------------ * CAST float <- long- [000025] ------------ \--* CNS_INT long 0-Bashed to fp constant:- [000026] ------------ * CNS_DBL float 0.0000000000000000-
[ 2] 112 (0x070) conv.u8
-Folding long operator with constant nodes into a constant:- [000027] ------------ * CAST long <- ulong <- float- [000026] ------------ \--* CNS_DBL float 0.0000000000000000-Bashed to long constant:- [000027] ------------ * CNS_INT long 0-
[ 2] 113 (0x071) mul
[ 1] 114 (0x072) ldc.r4 2281166340096.0000
[ 2] 119 (0x077) ldc.r8 -1.4862075407321284e+46
@@ -475,7 +457,10 @@ STMT00009 (IL ???... ???)
[000095] ---X-------- \--* ADD_ovfl long
[000028] ------------ +--* MUL long
[000018] ------------ | +--* CNS_INT long -0xf925aa1447c2972
- [000027] ------------ | \--* CNS_INT long 0+ [000027] ------------ | \--* CAST long <- ulong <- float+ [000026] ------------ | \--* CAST float <- long+ [000025] ------------ | \--* CAST long <- ulong <- double+ [000024] ------------ | \--* CNS_DBL double 5.6605893542014790e+65
[000094] ---X-------- \--* SUB_ovfl long

Case 2: ILGEN_1806854430:main():int, 42 (700.00% of base):

- mov eax, 100- ;; bbWeight=1 PerfScore 0.25+ vcvttss2si rax, qword ptr [reloc @RWD00]+ cmp rax, 0xD1FFAB1E+ setl dl+ movzx rdx, dl+ movsxd rdx, edx+ cmp rdx, rax+ setg al+ movzx rax, al+ cmp eax, 0xD1FFAB1E+ seta al+ movzx rax, al+ add eax, 100+ ;; bbWeight=1 PerfScore 12.00
G_M58196_IG03: ; , epilog, nogc, extend
ret
;; bbWeight=1 PerfScore 1.00
+RWD00 dd 63E756A3h ; 8.53488e+21

This time, local assertion propagation does not result in gtFoldExprConst folding the expressions in post-order morph:

@@ -518,56 +512,35 @@ Assertion prop in BB01:
Constant Assertion: V00 == 8.53488e+21 index=#01, mask=0000000000000001
[000020] ------------ * CNS_DBL float 8.5348814290707441e+21
-Folding long operator with constant nodes into a constant:- [000021] ------------ * CAST long <- float- [000020] -----+------ \--* CNS_DBL float 8.5348814290707441e+21-Bashed to long constant:- [000021] ------------ * CNS_INT long -0x8000000000000000--Folding operator with constant nodes into a constant:- [000023] ------------ * GT int- [000022] -----+------ +--* CNS_INT long 0x45E23077- [000021] -----+------ \--* CNS_INT long -0x8000000000000000-Bashed to int constant:- [000023] ------------ * CNS_INT int 1--Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- int- [000023] -----+------ \--* CNS_INT int 1-Bashed to long constant:- [000025] ------------ * CNS_INT long 1

Case 3: ConvTest:test1():byte, 16 (44.44% of base):

 G_M30804_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,22 @@ G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- xor ecx, ecx+ vcvttsd2si ecx, dword ptr [reloc @RWD00]+ movsx rsi, cl+ mov ecx, esi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- xor eax, eax- ;; bbWeight=1 PerfScore 4.75+ movsx rax, sil+ ;; bbWeight=1 PerfScore 12.00
G_M30804_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)

Here, VN block takes hold:

 N001 [000002] CNS_DBL -nan(ind) => $140 {DblCns[-nan(ind)]}
VNForCastOper(int) is $41
-N002 [000013] CAST => $42 {IntCns 0x80000000}- VNForCastOper(byte) is $43-N003 [000003] CAST => $44 {IntCns 0}-N004 [000004] LCL_VAR V01 tmp1 d:1 => $44 {IntCns 0}-N005 [000005] ASG => $44 {IntCns 0}+N002 [000013] CAST => $180 {Cast($140, $41)}+ VNForCastOper(byte) is $42+N003 [000003] CAST => $181 {Cast($180, $42)}+N004 [000004] LCL_VAR V01 tmp1 d:1 => $181 {Cast($180, $42)}+N005 [000005] ASG => $181 {Cast($180, $42)}
***** BB01, STMT00001(after)
-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $44-N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $42+N005 ( 10, 12) [000005] -A------R--- * ASG int $181+N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $181+N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $181+N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $180
N001 ( 3, 4) [000002] ------------ \--* CNS_DBL double -nan(ind) $140

This means no constant propagation in assertion prop:

-After constant propagation on [000003]:-STMT00001 (IL 0x00A... ???)-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44- [000016] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N003 ( 1, 3) [000005] -A------R--- * ASG int $44-N002 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N001 ( 1, 1) [000016] ------------ \--* CNS_INT int 0 $44--After constant propagation on [000007]:-STMT00002 (IL ???... ???)-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void- [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44-ReMorphing args for 8.CALL:-argSlots=1, preallocatedArgCount=4, nextSlotNum=4, nextSlotByteOffset=32, outgoingArgSpaceSize=32-ArgTable for 8.CALL after fgMorphArgs:-fgArgTabEntry[arg 0 17.CNS_INT int (By ref), 1 reg: rcx, byteAlignment=8, lateArgInx=0, processed]--optVNAssertionPropCurStmt morphed tree:-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void-N002 ( 1, 1) [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44--After constant propagation on [000015]:-STMT00003 (IL 0x01A... ???)-N003 ( 3, 4) [000009] ------------ * RETURN int $182- [000018] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N002 ( 2, 2) [000009] ------------ * RETURN int $182-N001 ( 1, 1) [000018] ------------ \--* CNS_INT int 0 $44

Case 4: ConvTest:test4():long, -3 (-5.77% of base):

-; Lcl frame size = 40+; Lcl frame size = 32
G_M60593_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,21 @@ G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- mov rcx, 0xD1FFAB1E+ vcvttsd2si rsi, qword ptr [reloc @RWD00]+ mov rcx, rsi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- mov rax, 0xD1FFAB1E- ;; bbWeight=1 PerfScore 4.75+ mov rax, rsi+ ;; bbWeight=1 PerfScore 11.75
G_M60593_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)+-; Total bytes of code 52, prolog size 4, PerfScore 11.45, instruction count 9, allocated bytes for code 52 (MethodHash=1dad134e) for method ConvTest:test4():long+; Total bytes of code 49, prolog size 5, PerfScore 19.65, instruction count 12, allocated bytes for code 49 (MethodHash=1dad134e) for method ConvTest:test4():long

This is another case of no folding in VN:

-N002 [000003] CAST => $180 {LngCns: 0x8000000000000000}-N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {LngCns: 0x8000000000000000}-N004 [000005] ASG => $180 {LngCns: 0x8000000000000000}+N002 [000003] CAST => $180 {Cast($140, $41)}+N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {Cast($140, $41)}+N004 [000005] ASG => $180 {Cast($140, $41)}

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution!

Where they originally were.
@kunalspathak

Copy link
Copy Markdown
Contributor

@SingleAccretion - do you mind taking a look into failures to make sure they are not related to your changes?

@SingleAccretion

SingleAccretion commented Jul 7, 2021

Copy link
Copy Markdown
ContributorAuthor

do you mind taking a look into failures to make sure they are not related to your changes?

@kunalspathak yes of course. Unfortunately the CI is not in the greatest of shapes right now :(.

  1. Build Android x64 Release AllSubsets_Mono_RuntimeTests - log, looks like an infrastructure problem:
[21:26:28] fail: Cannot find a device with app=package:net.dot.JIT_CodeGenBringUpTests, please check that a device is attached
XHarness exit code: 85 (ADB_DEVICE_ENUMERATION_FAILURE)
Test Harness Exitcode is : 85
  1. Build tvOS arm64 Release AllSubsets_Mono - restore failed:
.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : (NETCORE_ENGINEERING_TELEMETRY=Restore) Failed to download package 'Microsoft.Private.Intellisense.5.0.0-preview-20201009.2' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.private.intellisense/5.0.0-preview-20201009.2/microsoft.private.intellisense.5.0.0-preview-20201009.2.nupkg'.
Response status code does not indicate success: 503 (Service Unavailable - TF10216: Azure DevOps services are currently unavailable. Try again later. Activity Id: 84ef9393-5dd8-434a-80b7-f2eb40580efb (DevOps Activity ID: 84EF9393-5DD8-434A-80B7-F2EB40580EFB)).
  1. CoreCLR Product Build OSX arm64 checked - log, another restore failure:
2021-07-06T20:40:41.9426000Z /Users/runner/work/1/s/.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : Failed to download package 'System.Linq.4.1.0-rc2-24027' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/system.linq/4.1.0-rc2-24027/system.linq.4.1.0-rc2-24027.nupkg'. [/Users/runner/work/1/s/src/tests/Common/external/external.csproj] [/Users/runner/work/1/s/src/tests/build.proj]
  1. Libraries Test Run checked coreclr Linux_musl arm Release - log, this time a real test failure:
 Discovering: System.Text.Encoding.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.Text.Encoding.Tests (found 338 of 341 test cases)
Starting: System.Text.Encoding.Tests (parallel test collections = on, max threads = 4)
System.Text.Tests.TranscodingStreamTests.Read_Span(bufferLength: 1) [FAIL]
Assert.Equal() Failure
↓ (pos 4839671)
Expected: ···lmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
Actual: ···lmnopqrstuvwxyzabcdeFghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
↑ (pos 4839671)

This looks like #47444. Seeing as this is a rare failure, maybe we can extract some useful information from this run...?

  1. Libraries Test Run release coreclr Linux x64 Debug - log, another test failure:
System.Net.Http.Functional.Tests.SocketsHttpHandler_HttpClientHandler_ConnectionPooling_Test.Http2_SmallConnectionTimeout_SubsequentRequestUsesDifferentConnection(timeoutPropertyName: "PooledConnectionLifetime") [FAIL]
System.IO.IOException : Unable to write data to the transport connection: Broken pipe.
  1. runtime-dev-innerloop, build #20210706.55, runtime-dev-innerloop, Build OSX x64 release Runtime_Debug, runtime-staging (Build iOSSimulator x64 Release AllSubsets_Mono) - more restore failures.

  2. runtime-staging, many failures - log1, log2, log3 (there are others), not enough space on the device:

Standard Error:
adb: failed to install /datadisks/disk1/work/A1BB08F0/w/B3F70977/e/System.DirectoryServices.Protocols.Tests.apk: Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
  1. runtime-staging, an interpreter test failure - log

  2. runtime-staging, many System.Drawing.Imaging failures (this is Mono on Windows), PNSEs:

 System.Drawing.Imaging.Tests.MetafileTests.Ctor_InvalidEmfTypeIII_ThrowsArgumentException(emfType: 2) [FAIL]
Assert.Throws() Failure
Expected: typeof(System.ArgumentException)
Actual: typeof(System.TypeInitializationException): The type initializer for 'System.Drawing.DrawingCom' threw an exception.
---- System.TypeInitializationException : The type initializer for 'System.Drawing.DrawingCom' threw an exception.

A rich assortment to be sure...

"Real" failures seem to be HTTP one, and the interpreter one, though I find it hard to see how they could be caused by this change (note as well that it passed CI on first run, and no code changes have been committed since).

@kunalspathak
kunalspathak merged commit 527e566 into dotnet:mainJul 7, 2021
@SingleAccretion
SingleAccretion deleted the Disable-Folding-For-Implementation-Defined-Casts branch July 8, 2021 21:21
@ghostghost locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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.

System.Linq.Expressions tests are broken in CI System.Linq.Expressions tests failing on some PRs

4 participants

@SingleAccretion@tannergooding@JulieLeeMSFT@kunalspathak
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Disable folding of implementation-defined casts - #53782

Merged
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts
Jul 7, 2021
Merged

Disable folding of implementation-defined casts#53782
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts

Conversation

@SingleAccretion

@SingleAccretionSingleAccretion commented Jun 6, 2021

Copy link
Copy Markdown
Contributor

With #51440 merged, it is now easy to do the intended second part of that PR and disable folding of all implementation-defined float/double -> integer casts. This is a temporary solution to #47478, but without it I will not be able to move forward with the casts work as a lot of this has so far been masked by the fact that problematic conversions were being morphed into calls and thus not getting folded.

For the diffs, the expectation is that there will be some regressions in coreclr_tests.

Windows x64
Running asm diffs of coreclr_tests.pmi.windows.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49048
Total bytes of diff: 50724
Total bytes of delta: 1676 (3.42% of base)
diff is a regression.
Top method regressions (bytes):
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
95 (30.16% of base) - FloatOvfToInt:TestValuesDoubleInt():int
95 (30.16% of base) - FloatOvfToInt:TestValuesFloatInt():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
59 ( 0.23% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
49 (13.14% of base) - ILGEN_0xe696696:main():int
42 (15.05% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
42 (700.00% of base) - ILGEN_1806854430:main():int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
39 (31.97% of base) - FloatOvfToInt:TestValuesFloatShort():int
38 (19.29% of base) - ILGEN_622380794:main():int
33 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
32 (25.00% of base) - FloatOvfToInt:TestValuesFloatInt():int
32 (25.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (bytes):
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-4 (-5.71% of base) - C:L(float):float
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
Top method regressions (percentages):
42 (700.00% of base) - ILGEN_1806854430:main():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
14 (38.89% of base) - ConvTest:test8():ushort
14 (38.89% of base) - ConvTest:test8():ushort
17 (37.78% of base) - ILGEN_0x64f58bd0:Method_0x1bb0(int,long,float,int,int):int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
Top method improvements (percentages):
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-4 (-5.71% of base) - C:L(float):float
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
67 total methods with Code Size differences (9 improved, 58 regressed), 0 unchanged.
Windows x86
Running asm diffs of coreclr_tests.pmi.windows.x86.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 50715
Total bytes of diff: 52539
Total bytes of delta: 1824 (3.60% of base)
diff is a regression.
Top method regressions (bytes):
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleByte():int
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleShort():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatByte():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatShort():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (23.50% of base) - ILGEN_0xe696696:main():int
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
48 (12.66% of base) - DevDiv_590771:ILGEN_METHOD(long,ushort,int,int,ushort,int):byte
47 ( 8.58% of base) - FloatOvfToInt:TestValuesDoubleInt():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
37 ( 6.75% of base) - FloatOvfToInt:TestValuesFloatInt():int
36 (600.00% of base) - ILGEN_1806854430:main():int
36 (13.90% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
34 ( 5.87% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
32 (12.85% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-8 (-5.23% of base) - C:Main():int
-8 (-7.02% of base) - C:L(float):float
Top method regressions (percentages):
36 (600.00% of base) - ILGEN_1806854430:main():int
24 (400.00% of base) - ILGEN_622380794:main():int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
21 (75.00% of base) - ILGEN_0xb6f84258:Main():int
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test7():ubyte
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test7():ubyte
3 (37.50% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
Top method improvements (percentages):
-8 (-7.02% of base) - C:L(float):float
-8 (-5.23% of base) - C:Main():int
61 total methods with Code Size differences (2 improved, 59 regressed), 0 unchanged.
Linux x64
Running asm diffs of coreclr_tests.pmi.Linux.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 48680
Total bytes of diff: 50694
Total bytes of delta: 2014 (4.14% of base)
diff is a regression.
Top method regressions (bytes):
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
137 (49.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
131 (47.29% of base) - FloatOvfToInt:TestValuesDoubleShort():int
131 (47.29% of base) - FloatOvfToInt:TestValuesFloatShort():int
115 (37.95% of base) - FloatOvfToInt:TestValuesFloatInt():int
115 (37.95% of base) - FloatOvfToInt:TestValuesDoubleInt():int
78 (36.11% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
60 (15.67% of base) - ILGEN_0xe696696:main():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
53 ( 0.22% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
52 (44.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
52 (44.83% of base) - FloatOvfToInt:TestValuesDoubleInt():int
44 (733.33% of base) - ILGEN_1806854430:main():int
42 (16.03% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
38 (16.24% of base) - ILGEN_622380794:main():int
34 (26.77% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
Top method improvements (bytes):
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-8 (-13.11% of base) - C:L(float):float
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
Top method regressions (percentages):
44 (733.33% of base) - ILGEN_1806854430:main():int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test2():short
23 (69.70% of base) - ConvTest:test2():short
22 (66.67% of base) - ConvTest:test7():ubyte
22 (66.67% of base) - ConvTest:test7():ubyte
21 (63.64% of base) - ConvTest:test8():ushort
21 (63.64% of base) - ConvTest:test8():ushort
18 (54.55% of base) - ConvTest:test9():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test9():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
Top method improvements (percentages):
-8 (-13.11% of base) - C:L(float):float
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
65 total methods with Code Size differences (8 improved, 57 regressed), 2 unchanged.
Linux ARM64
Running asm diffs of coreclr_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 51232
Total bytes of diff: 54080
Total bytes of delta: 2848 (5.56% of base)
diff is a regression.
Top method regressions (bytes):
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (35.53% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
64 (12.40% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (18.52% of base) - FloatOvfToInt:TestValuesFloatLong():int
60 (18.52% of base) - FloatOvfToInt:TestValuesDoubleLong():int
60 (14.15% of base) - ILGEN_0xe696696:main():int
52 (260.00% of base) - ILGEN_1806854430:main():int
44 (26.83% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
44 (12.36% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
44 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
40 ( 7.75% of base) - ILGEN_0x57cc69ce:Method_0x183df1b1():int
Top method improvements (bytes):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
Top method regressions (percentages):
52 (260.00% of base) - ILGEN_1806854430:main():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
28 (53.85% of base) - ILGEN_0x77e65197:Main():int
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test7():ubyte
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test7():ubyte
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (percentages):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
78 total methods with Code Size differences (1 improved, 77 regressed), 2 unchanged.
Running asm diffs of libraries_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 932
Total bytes of diff: 968
Total bytes of delta: 36 (3.86% of base)
diff is a regression.
Top method regressions (bytes):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
Top method regressions (percentages):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
1 total methods with Code Size differences (0 improved, 1 regressed), 6 unchanged.
Linux ARM
Running asm diffs of coreclr_tests.pmi.Linux.arm.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49502
Total bytes of diff: 52992
Total bytes of delta: 3490 (7.05% of base)
diff is a regression.
Top method regressions (bytes):
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleShort():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleByte():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatShort():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatByte():int
122 (26.18% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (34.96% of base) - ILGEN_622380794:main():int
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
84 (28.77% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
70 ( 0.29% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,int,ushort,double,long,long):int
66 (16.10% of base) - ILGEN_0xe696696:main():int
66 (1,100.00% of base) - ILGEN_1806854430:main():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
66 (12.94% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (1,000.00% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-10 (-11.36% of base) - C:L(float):float
Top method regressions (percentages):
66 (1,100.00% of base) - ILGEN_1806854430:main():int
60 (1,000.00% of base) - ILGEN_622380794:main():int
12 (150.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
44 (146.67% of base) - ILGEN_0xb6f84258:Main():int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
26 (59.09% of base) - ConvTest:test2():short
26 (59.09% of base) - ConvTest:test8():ushort
26 (59.09% of base) - ConvTest:test1():byte
26 (59.09% of base) - ConvTest:test7():ubyte
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
24 (54.55% of base) - ConvTest:test1():byte
24 (54.55% of base) - ConvTest:test2():short
24 (54.55% of base) - ConvTest:test7():ubyte
24 (54.55% of base) - ConvTest:test8():ushort
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
Top method improvements (percentages):
-10 (-11.36% of base) - C:L(float):float
66 total methods with Code Size differences (1 improved, 65 regressed), 1 unchanged.

Which the replays confirm.

Closes#51346.
Closes#47374.

It is not very effective right now because the "bad" combinations of
types are morphed into helpers too early, but it will be helpful when
we enable folding outside of the importer for those cases too.
It now fails on Windows x86, where many of the
previous similar failures were observed.
@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 6, 2021
@SingleAccretionSingleAccretion changed the title Disable folding for implementation-defined castsDisable folding of implementation-defined castsJun 6, 2021
@SingleAccretion
SingleAccretionforce-pushed the Disable-Folding-For-Implementation-Defined-Casts branch from d47687b to d13b563CompareJune 6, 2021 16:51
@SingleAccretion
SingleAccretion marked this pull request as ready for review June 7, 2021 20:19
@tannergooding

Copy link
Copy Markdown
Member

CC. @dotnet/jit-contrib, community PR

@JulieLeeMSFT

Copy link
Copy Markdown
Member

@kunalspathak PTAL for community PR.

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added some questions. Could you share some of the sample diffs that you see in the test (just to understand how this works underlying). Also, did you check asmdiffs on benchmarks/libraries?

Comment threadsrc/coreclr/jit/valuenum.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Also, did you check asmdiffs on benchmarks/libraries?

Yep, the PR's header is for results of running SPMI over all available collections, so, no diffs outside tests.

Could you share some of the sample diffs that you see in the test (just to understand how this works underlying).

Will recollect the diffs and share the samples.

@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Case 1: ILGEN_0x44f8f663:Method_0x2e75f3b4, 76 (133.33% of base):

 G_M64081_IG01:
sub rsp, 40
-+ vzeroupper+
G_M64081_IG02:
movsx rcx, cl
xor ecx, 5
@@ -25,22 +26,41 @@ G_M64081_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, isz
add rcx, rax
mov rax, rcx
shr rax, 32
- jne SHORT G_M64081_IG03+ jne SHORT G_M64081_IG04
xor ecx, ecx
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
- xor ecx, ecx- call CORINFO_HELP_OVERFLOW+ vmovsd xmm0, qword ptr [reloc @RWD00]+ call CORINFO_HELP_DBL2ULNG
; gcr arg pop 0
- int3- ;; bbWeight=1 PerfScore 5.75-G_M64081_IG03: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref+ vxorps xmm0, xmm0+ vcvtsi2ss xmm0, rax+ vcvtss2sd xmm0, xmm0+ call CORINFO_HELP_DBL2ULNG+ ; gcr arg pop 0+ mov rdx, 0xD1FFAB1E+ imul rax, rdx+ mov rdx, 0xD1FFAB1E+ add rax, rdx+ jo SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jg SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jl SHORT G_M64081_IG04+ ;; bbWeight=1 PerfScore 23.83+G_M64081_IG03: ; , epilog, nogc, extend+ add rsp, 40+ ret+ ;; bbWeight=1 PerfScore 1.25+G_M64081_IG04: ; gcVars=0000000000000000 {}, gcrefRegs=00000000 {}, byrefRegs=00000000 {}, gcvars, byref
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
int3
;; bbWeight=0 PerfScore 0.00
+RWD00 dq 4D95800D5C7F3082h ; 5.66058935e+65

Here the early importer folding is blocked, due to the new checks in gtFoldExprConst:

 [ 1] 100 (0x064) nop
[ 1] 101 (0x065) ldc.r8 5.6605893542014790e+65
[ 2] 110 (0x06e) conv.u
-Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- ulong <- double- [000024] ------------ \--* CNS_DBL double 5.6605893542014790e+65-Bashed to long constant:- [000025] ------------ * CNS_INT long 0-
[ 2] 111 (0x06f) conv.r4
-Folding fp operator with constant nodes into a fp constant:- [000026] ------------ * CAST float <- long- [000025] ------------ \--* CNS_INT long 0-Bashed to fp constant:- [000026] ------------ * CNS_DBL float 0.0000000000000000-
[ 2] 112 (0x070) conv.u8
-Folding long operator with constant nodes into a constant:- [000027] ------------ * CAST long <- ulong <- float- [000026] ------------ \--* CNS_DBL float 0.0000000000000000-Bashed to long constant:- [000027] ------------ * CNS_INT long 0-
[ 2] 113 (0x071) mul
[ 1] 114 (0x072) ldc.r4 2281166340096.0000
[ 2] 119 (0x077) ldc.r8 -1.4862075407321284e+46
@@ -475,7 +457,10 @@ STMT00009 (IL ???... ???)
[000095] ---X-------- \--* ADD_ovfl long
[000028] ------------ +--* MUL long
[000018] ------------ | +--* CNS_INT long -0xf925aa1447c2972
- [000027] ------------ | \--* CNS_INT long 0+ [000027] ------------ | \--* CAST long <- ulong <- float+ [000026] ------------ | \--* CAST float <- long+ [000025] ------------ | \--* CAST long <- ulong <- double+ [000024] ------------ | \--* CNS_DBL double 5.6605893542014790e+65
[000094] ---X-------- \--* SUB_ovfl long

Case 2: ILGEN_1806854430:main():int, 42 (700.00% of base):

- mov eax, 100- ;; bbWeight=1 PerfScore 0.25+ vcvttss2si rax, qword ptr [reloc @RWD00]+ cmp rax, 0xD1FFAB1E+ setl dl+ movzx rdx, dl+ movsxd rdx, edx+ cmp rdx, rax+ setg al+ movzx rax, al+ cmp eax, 0xD1FFAB1E+ seta al+ movzx rax, al+ add eax, 100+ ;; bbWeight=1 PerfScore 12.00
G_M58196_IG03: ; , epilog, nogc, extend
ret
;; bbWeight=1 PerfScore 1.00
+RWD00 dd 63E756A3h ; 8.53488e+21

This time, local assertion propagation does not result in gtFoldExprConst folding the expressions in post-order morph:

@@ -518,56 +512,35 @@ Assertion prop in BB01:
Constant Assertion: V00 == 8.53488e+21 index=#01, mask=0000000000000001
[000020] ------------ * CNS_DBL float 8.5348814290707441e+21
-Folding long operator with constant nodes into a constant:- [000021] ------------ * CAST long <- float- [000020] -----+------ \--* CNS_DBL float 8.5348814290707441e+21-Bashed to long constant:- [000021] ------------ * CNS_INT long -0x8000000000000000--Folding operator with constant nodes into a constant:- [000023] ------------ * GT int- [000022] -----+------ +--* CNS_INT long 0x45E23077- [000021] -----+------ \--* CNS_INT long -0x8000000000000000-Bashed to int constant:- [000023] ------------ * CNS_INT int 1--Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- int- [000023] -----+------ \--* CNS_INT int 1-Bashed to long constant:- [000025] ------------ * CNS_INT long 1

Case 3: ConvTest:test1():byte, 16 (44.44% of base):

 G_M30804_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,22 @@ G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- xor ecx, ecx+ vcvttsd2si ecx, dword ptr [reloc @RWD00]+ movsx rsi, cl+ mov ecx, esi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- xor eax, eax- ;; bbWeight=1 PerfScore 4.75+ movsx rax, sil+ ;; bbWeight=1 PerfScore 12.00
G_M30804_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)

Here, VN block takes hold:

 N001 [000002] CNS_DBL -nan(ind) => $140 {DblCns[-nan(ind)]}
VNForCastOper(int) is $41
-N002 [000013] CAST => $42 {IntCns 0x80000000}- VNForCastOper(byte) is $43-N003 [000003] CAST => $44 {IntCns 0}-N004 [000004] LCL_VAR V01 tmp1 d:1 => $44 {IntCns 0}-N005 [000005] ASG => $44 {IntCns 0}+N002 [000013] CAST => $180 {Cast($140, $41)}+ VNForCastOper(byte) is $42+N003 [000003] CAST => $181 {Cast($180, $42)}+N004 [000004] LCL_VAR V01 tmp1 d:1 => $181 {Cast($180, $42)}+N005 [000005] ASG => $181 {Cast($180, $42)}
***** BB01, STMT00001(after)
-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $44-N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $42+N005 ( 10, 12) [000005] -A------R--- * ASG int $181+N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $181+N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $181+N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $180
N001 ( 3, 4) [000002] ------------ \--* CNS_DBL double -nan(ind) $140

This means no constant propagation in assertion prop:

-After constant propagation on [000003]:-STMT00001 (IL 0x00A... ???)-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44- [000016] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N003 ( 1, 3) [000005] -A------R--- * ASG int $44-N002 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N001 ( 1, 1) [000016] ------------ \--* CNS_INT int 0 $44--After constant propagation on [000007]:-STMT00002 (IL ???... ???)-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void- [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44-ReMorphing args for 8.CALL:-argSlots=1, preallocatedArgCount=4, nextSlotNum=4, nextSlotByteOffset=32, outgoingArgSpaceSize=32-ArgTable for 8.CALL after fgMorphArgs:-fgArgTabEntry[arg 0 17.CNS_INT int (By ref), 1 reg: rcx, byteAlignment=8, lateArgInx=0, processed]--optVNAssertionPropCurStmt morphed tree:-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void-N002 ( 1, 1) [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44--After constant propagation on [000015]:-STMT00003 (IL 0x01A... ???)-N003 ( 3, 4) [000009] ------------ * RETURN int $182- [000018] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N002 ( 2, 2) [000009] ------------ * RETURN int $182-N001 ( 1, 1) [000018] ------------ \--* CNS_INT int 0 $44

Case 4: ConvTest:test4():long, -3 (-5.77% of base):

-; Lcl frame size = 40+; Lcl frame size = 32
G_M60593_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,21 @@ G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- mov rcx, 0xD1FFAB1E+ vcvttsd2si rsi, qword ptr [reloc @RWD00]+ mov rcx, rsi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- mov rax, 0xD1FFAB1E- ;; bbWeight=1 PerfScore 4.75+ mov rax, rsi+ ;; bbWeight=1 PerfScore 11.75
G_M60593_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)+-; Total bytes of code 52, prolog size 4, PerfScore 11.45, instruction count 9, allocated bytes for code 52 (MethodHash=1dad134e) for method ConvTest:test4():long+; Total bytes of code 49, prolog size 5, PerfScore 19.65, instruction count 12, allocated bytes for code 49 (MethodHash=1dad134e) for method ConvTest:test4():long

This is another case of no folding in VN:

-N002 [000003] CAST => $180 {LngCns: 0x8000000000000000}-N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {LngCns: 0x8000000000000000}-N004 [000005] ASG => $180 {LngCns: 0x8000000000000000}+N002 [000003] CAST => $180 {Cast($140, $41)}+N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {Cast($140, $41)}+N004 [000005] ASG => $180 {Cast($140, $41)}

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution!

Where they originally were.
@kunalspathak

Copy link
Copy Markdown
Contributor

@SingleAccretion - do you mind taking a look into failures to make sure they are not related to your changes?

@SingleAccretion

SingleAccretion commented Jul 7, 2021

Copy link
Copy Markdown
ContributorAuthor

do you mind taking a look into failures to make sure they are not related to your changes?

@kunalspathak yes of course. Unfortunately the CI is not in the greatest of shapes right now :(.

  1. Build Android x64 Release AllSubsets_Mono_RuntimeTests - log, looks like an infrastructure problem:
[21:26:28] fail: Cannot find a device with app=package:net.dot.JIT_CodeGenBringUpTests, please check that a device is attached
XHarness exit code: 85 (ADB_DEVICE_ENUMERATION_FAILURE)
Test Harness Exitcode is : 85
  1. Build tvOS arm64 Release AllSubsets_Mono - restore failed:
.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : (NETCORE_ENGINEERING_TELEMETRY=Restore) Failed to download package 'Microsoft.Private.Intellisense.5.0.0-preview-20201009.2' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.private.intellisense/5.0.0-preview-20201009.2/microsoft.private.intellisense.5.0.0-preview-20201009.2.nupkg'.
Response status code does not indicate success: 503 (Service Unavailable - TF10216: Azure DevOps services are currently unavailable. Try again later. Activity Id: 84ef9393-5dd8-434a-80b7-f2eb40580efb (DevOps Activity ID: 84EF9393-5DD8-434A-80B7-F2EB40580EFB)).
  1. CoreCLR Product Build OSX arm64 checked - log, another restore failure:
2021-07-06T20:40:41.9426000Z /Users/runner/work/1/s/.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : Failed to download package 'System.Linq.4.1.0-rc2-24027' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/system.linq/4.1.0-rc2-24027/system.linq.4.1.0-rc2-24027.nupkg'. [/Users/runner/work/1/s/src/tests/Common/external/external.csproj] [/Users/runner/work/1/s/src/tests/build.proj]
  1. Libraries Test Run checked coreclr Linux_musl arm Release - log, this time a real test failure:
 Discovering: System.Text.Encoding.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.Text.Encoding.Tests (found 338 of 341 test cases)
Starting: System.Text.Encoding.Tests (parallel test collections = on, max threads = 4)
System.Text.Tests.TranscodingStreamTests.Read_Span(bufferLength: 1) [FAIL]
Assert.Equal() Failure
↓ (pos 4839671)
Expected: ···lmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
Actual: ···lmnopqrstuvwxyzabcdeFghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
↑ (pos 4839671)

This looks like #47444. Seeing as this is a rare failure, maybe we can extract some useful information from this run...?

  1. Libraries Test Run release coreclr Linux x64 Debug - log, another test failure:
System.Net.Http.Functional.Tests.SocketsHttpHandler_HttpClientHandler_ConnectionPooling_Test.Http2_SmallConnectionTimeout_SubsequentRequestUsesDifferentConnection(timeoutPropertyName: "PooledConnectionLifetime") [FAIL]
System.IO.IOException : Unable to write data to the transport connection: Broken pipe.
  1. runtime-dev-innerloop, build #20210706.55, runtime-dev-innerloop, Build OSX x64 release Runtime_Debug, runtime-staging (Build iOSSimulator x64 Release AllSubsets_Mono) - more restore failures.

  2. runtime-staging, many failures - log1, log2, log3 (there are others), not enough space on the device:

Standard Error:
adb: failed to install /datadisks/disk1/work/A1BB08F0/w/B3F70977/e/System.DirectoryServices.Protocols.Tests.apk: Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
  1. runtime-staging, an interpreter test failure - log

  2. runtime-staging, many System.Drawing.Imaging failures (this is Mono on Windows), PNSEs:

 System.Drawing.Imaging.Tests.MetafileTests.Ctor_InvalidEmfTypeIII_ThrowsArgumentException(emfType: 2) [FAIL]
Assert.Throws() Failure
Expected: typeof(System.ArgumentException)
Actual: typeof(System.TypeInitializationException): The type initializer for 'System.Drawing.DrawingCom' threw an exception.
---- System.TypeInitializationException : The type initializer for 'System.Drawing.DrawingCom' threw an exception.

A rich assortment to be sure...

"Real" failures seem to be HTTP one, and the interpreter one, though I find it hard to see how they could be caused by this change (note as well that it passed CI on first run, and no code changes have been committed since).

@kunalspathak
kunalspathak merged commit 527e566 into dotnet:mainJul 7, 2021
@SingleAccretion
SingleAccretion deleted the Disable-Folding-For-Implementation-Defined-Casts branch July 8, 2021 21:21
@ghostghost locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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.

System.Linq.Expressions tests are broken in CI System.Linq.Expressions tests failing on some PRs

4 participants

@SingleAccretion@tannergooding@JulieLeeMSFT@kunalspathak
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Disable folding of implementation-defined casts - #53782

Merged
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts
Jul 7, 2021
Merged

Disable folding of implementation-defined casts#53782
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts

Conversation

@SingleAccretion

@SingleAccretionSingleAccretion commented Jun 6, 2021

Copy link
Copy Markdown
Contributor

With #51440 merged, it is now easy to do the intended second part of that PR and disable folding of all implementation-defined float/double -> integer casts. This is a temporary solution to #47478, but without it I will not be able to move forward with the casts work as a lot of this has so far been masked by the fact that problematic conversions were being morphed into calls and thus not getting folded.

For the diffs, the expectation is that there will be some regressions in coreclr_tests.

Windows x64
Running asm diffs of coreclr_tests.pmi.windows.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49048
Total bytes of diff: 50724
Total bytes of delta: 1676 (3.42% of base)
diff is a regression.
Top method regressions (bytes):
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
95 (30.16% of base) - FloatOvfToInt:TestValuesDoubleInt():int
95 (30.16% of base) - FloatOvfToInt:TestValuesFloatInt():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
59 ( 0.23% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
49 (13.14% of base) - ILGEN_0xe696696:main():int
42 (15.05% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
42 (700.00% of base) - ILGEN_1806854430:main():int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
39 (31.97% of base) - FloatOvfToInt:TestValuesFloatShort():int
38 (19.29% of base) - ILGEN_622380794:main():int
33 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
32 (25.00% of base) - FloatOvfToInt:TestValuesFloatInt():int
32 (25.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (bytes):
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-4 (-5.71% of base) - C:L(float):float
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
Top method regressions (percentages):
42 (700.00% of base) - ILGEN_1806854430:main():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
14 (38.89% of base) - ConvTest:test8():ushort
14 (38.89% of base) - ConvTest:test8():ushort
17 (37.78% of base) - ILGEN_0x64f58bd0:Method_0x1bb0(int,long,float,int,int):int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
Top method improvements (percentages):
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-4 (-5.71% of base) - C:L(float):float
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
67 total methods with Code Size differences (9 improved, 58 regressed), 0 unchanged.
Windows x86
Running asm diffs of coreclr_tests.pmi.windows.x86.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 50715
Total bytes of diff: 52539
Total bytes of delta: 1824 (3.60% of base)
diff is a regression.
Top method regressions (bytes):
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleByte():int
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleShort():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatByte():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatShort():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (23.50% of base) - ILGEN_0xe696696:main():int
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
48 (12.66% of base) - DevDiv_590771:ILGEN_METHOD(long,ushort,int,int,ushort,int):byte
47 ( 8.58% of base) - FloatOvfToInt:TestValuesDoubleInt():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
37 ( 6.75% of base) - FloatOvfToInt:TestValuesFloatInt():int
36 (600.00% of base) - ILGEN_1806854430:main():int
36 (13.90% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
34 ( 5.87% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
32 (12.85% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-8 (-5.23% of base) - C:Main():int
-8 (-7.02% of base) - C:L(float):float
Top method regressions (percentages):
36 (600.00% of base) - ILGEN_1806854430:main():int
24 (400.00% of base) - ILGEN_622380794:main():int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
21 (75.00% of base) - ILGEN_0xb6f84258:Main():int
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test7():ubyte
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test7():ubyte
3 (37.50% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
Top method improvements (percentages):
-8 (-7.02% of base) - C:L(float):float
-8 (-5.23% of base) - C:Main():int
61 total methods with Code Size differences (2 improved, 59 regressed), 0 unchanged.
Linux x64
Running asm diffs of coreclr_tests.pmi.Linux.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 48680
Total bytes of diff: 50694
Total bytes of delta: 2014 (4.14% of base)
diff is a regression.
Top method regressions (bytes):
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
137 (49.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
131 (47.29% of base) - FloatOvfToInt:TestValuesDoubleShort():int
131 (47.29% of base) - FloatOvfToInt:TestValuesFloatShort():int
115 (37.95% of base) - FloatOvfToInt:TestValuesFloatInt():int
115 (37.95% of base) - FloatOvfToInt:TestValuesDoubleInt():int
78 (36.11% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
60 (15.67% of base) - ILGEN_0xe696696:main():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
53 ( 0.22% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
52 (44.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
52 (44.83% of base) - FloatOvfToInt:TestValuesDoubleInt():int
44 (733.33% of base) - ILGEN_1806854430:main():int
42 (16.03% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
38 (16.24% of base) - ILGEN_622380794:main():int
34 (26.77% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
Top method improvements (bytes):
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-8 (-13.11% of base) - C:L(float):float
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
Top method regressions (percentages):
44 (733.33% of base) - ILGEN_1806854430:main():int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test2():short
23 (69.70% of base) - ConvTest:test2():short
22 (66.67% of base) - ConvTest:test7():ubyte
22 (66.67% of base) - ConvTest:test7():ubyte
21 (63.64% of base) - ConvTest:test8():ushort
21 (63.64% of base) - ConvTest:test8():ushort
18 (54.55% of base) - ConvTest:test9():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test9():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
Top method improvements (percentages):
-8 (-13.11% of base) - C:L(float):float
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
65 total methods with Code Size differences (8 improved, 57 regressed), 2 unchanged.
Linux ARM64
Running asm diffs of coreclr_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 51232
Total bytes of diff: 54080
Total bytes of delta: 2848 (5.56% of base)
diff is a regression.
Top method regressions (bytes):
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (35.53% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
64 (12.40% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (18.52% of base) - FloatOvfToInt:TestValuesFloatLong():int
60 (18.52% of base) - FloatOvfToInt:TestValuesDoubleLong():int
60 (14.15% of base) - ILGEN_0xe696696:main():int
52 (260.00% of base) - ILGEN_1806854430:main():int
44 (26.83% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
44 (12.36% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
44 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
40 ( 7.75% of base) - ILGEN_0x57cc69ce:Method_0x183df1b1():int
Top method improvements (bytes):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
Top method regressions (percentages):
52 (260.00% of base) - ILGEN_1806854430:main():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
28 (53.85% of base) - ILGEN_0x77e65197:Main():int
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test7():ubyte
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test7():ubyte
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (percentages):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
78 total methods with Code Size differences (1 improved, 77 regressed), 2 unchanged.
Running asm diffs of libraries_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 932
Total bytes of diff: 968
Total bytes of delta: 36 (3.86% of base)
diff is a regression.
Top method regressions (bytes):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
Top method regressions (percentages):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
1 total methods with Code Size differences (0 improved, 1 regressed), 6 unchanged.
Linux ARM
Running asm diffs of coreclr_tests.pmi.Linux.arm.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49502
Total bytes of diff: 52992
Total bytes of delta: 3490 (7.05% of base)
diff is a regression.
Top method regressions (bytes):
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleShort():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleByte():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatShort():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatByte():int
122 (26.18% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (34.96% of base) - ILGEN_622380794:main():int
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
84 (28.77% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
70 ( 0.29% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,int,ushort,double,long,long):int
66 (16.10% of base) - ILGEN_0xe696696:main():int
66 (1,100.00% of base) - ILGEN_1806854430:main():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
66 (12.94% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (1,000.00% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-10 (-11.36% of base) - C:L(float):float
Top method regressions (percentages):
66 (1,100.00% of base) - ILGEN_1806854430:main():int
60 (1,000.00% of base) - ILGEN_622380794:main():int
12 (150.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
44 (146.67% of base) - ILGEN_0xb6f84258:Main():int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
26 (59.09% of base) - ConvTest:test2():short
26 (59.09% of base) - ConvTest:test8():ushort
26 (59.09% of base) - ConvTest:test1():byte
26 (59.09% of base) - ConvTest:test7():ubyte
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
24 (54.55% of base) - ConvTest:test1():byte
24 (54.55% of base) - ConvTest:test2():short
24 (54.55% of base) - ConvTest:test7():ubyte
24 (54.55% of base) - ConvTest:test8():ushort
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
Top method improvements (percentages):
-10 (-11.36% of base) - C:L(float):float
66 total methods with Code Size differences (1 improved, 65 regressed), 1 unchanged.

Which the replays confirm.

Closes#51346.
Closes#47374.

It is not very effective right now because the "bad" combinations of
types are morphed into helpers too early, but it will be helpful when
we enable folding outside of the importer for those cases too.
It now fails on Windows x86, where many of the
previous similar failures were observed.
@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 6, 2021
@SingleAccretionSingleAccretion changed the title Disable folding for implementation-defined castsDisable folding of implementation-defined castsJun 6, 2021
@SingleAccretion
SingleAccretionforce-pushed the Disable-Folding-For-Implementation-Defined-Casts branch from d47687b to d13b563CompareJune 6, 2021 16:51
@SingleAccretion
SingleAccretion marked this pull request as ready for review June 7, 2021 20:19
@tannergooding

Copy link
Copy Markdown
Member

CC. @dotnet/jit-contrib, community PR

@JulieLeeMSFT

Copy link
Copy Markdown
Member

@kunalspathak PTAL for community PR.

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added some questions. Could you share some of the sample diffs that you see in the test (just to understand how this works underlying). Also, did you check asmdiffs on benchmarks/libraries?

Comment threadsrc/coreclr/jit/valuenum.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Also, did you check asmdiffs on benchmarks/libraries?

Yep, the PR's header is for results of running SPMI over all available collections, so, no diffs outside tests.

Could you share some of the sample diffs that you see in the test (just to understand how this works underlying).

Will recollect the diffs and share the samples.

@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Case 1: ILGEN_0x44f8f663:Method_0x2e75f3b4, 76 (133.33% of base):

 G_M64081_IG01:
sub rsp, 40
-+ vzeroupper+
G_M64081_IG02:
movsx rcx, cl
xor ecx, 5
@@ -25,22 +26,41 @@ G_M64081_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, isz
add rcx, rax
mov rax, rcx
shr rax, 32
- jne SHORT G_M64081_IG03+ jne SHORT G_M64081_IG04
xor ecx, ecx
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
- xor ecx, ecx- call CORINFO_HELP_OVERFLOW+ vmovsd xmm0, qword ptr [reloc @RWD00]+ call CORINFO_HELP_DBL2ULNG
; gcr arg pop 0
- int3- ;; bbWeight=1 PerfScore 5.75-G_M64081_IG03: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref+ vxorps xmm0, xmm0+ vcvtsi2ss xmm0, rax+ vcvtss2sd xmm0, xmm0+ call CORINFO_HELP_DBL2ULNG+ ; gcr arg pop 0+ mov rdx, 0xD1FFAB1E+ imul rax, rdx+ mov rdx, 0xD1FFAB1E+ add rax, rdx+ jo SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jg SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jl SHORT G_M64081_IG04+ ;; bbWeight=1 PerfScore 23.83+G_M64081_IG03: ; , epilog, nogc, extend+ add rsp, 40+ ret+ ;; bbWeight=1 PerfScore 1.25+G_M64081_IG04: ; gcVars=0000000000000000 {}, gcrefRegs=00000000 {}, byrefRegs=00000000 {}, gcvars, byref
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
int3
;; bbWeight=0 PerfScore 0.00
+RWD00 dq 4D95800D5C7F3082h ; 5.66058935e+65

Here the early importer folding is blocked, due to the new checks in gtFoldExprConst:

 [ 1] 100 (0x064) nop
[ 1] 101 (0x065) ldc.r8 5.6605893542014790e+65
[ 2] 110 (0x06e) conv.u
-Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- ulong <- double- [000024] ------------ \--* CNS_DBL double 5.6605893542014790e+65-Bashed to long constant:- [000025] ------------ * CNS_INT long 0-
[ 2] 111 (0x06f) conv.r4
-Folding fp operator with constant nodes into a fp constant:- [000026] ------------ * CAST float <- long- [000025] ------------ \--* CNS_INT long 0-Bashed to fp constant:- [000026] ------------ * CNS_DBL float 0.0000000000000000-
[ 2] 112 (0x070) conv.u8
-Folding long operator with constant nodes into a constant:- [000027] ------------ * CAST long <- ulong <- float- [000026] ------------ \--* CNS_DBL float 0.0000000000000000-Bashed to long constant:- [000027] ------------ * CNS_INT long 0-
[ 2] 113 (0x071) mul
[ 1] 114 (0x072) ldc.r4 2281166340096.0000
[ 2] 119 (0x077) ldc.r8 -1.4862075407321284e+46
@@ -475,7 +457,10 @@ STMT00009 (IL ???... ???)
[000095] ---X-------- \--* ADD_ovfl long
[000028] ------------ +--* MUL long
[000018] ------------ | +--* CNS_INT long -0xf925aa1447c2972
- [000027] ------------ | \--* CNS_INT long 0+ [000027] ------------ | \--* CAST long <- ulong <- float+ [000026] ------------ | \--* CAST float <- long+ [000025] ------------ | \--* CAST long <- ulong <- double+ [000024] ------------ | \--* CNS_DBL double 5.6605893542014790e+65
[000094] ---X-------- \--* SUB_ovfl long

Case 2: ILGEN_1806854430:main():int, 42 (700.00% of base):

- mov eax, 100- ;; bbWeight=1 PerfScore 0.25+ vcvttss2si rax, qword ptr [reloc @RWD00]+ cmp rax, 0xD1FFAB1E+ setl dl+ movzx rdx, dl+ movsxd rdx, edx+ cmp rdx, rax+ setg al+ movzx rax, al+ cmp eax, 0xD1FFAB1E+ seta al+ movzx rax, al+ add eax, 100+ ;; bbWeight=1 PerfScore 12.00
G_M58196_IG03: ; , epilog, nogc, extend
ret
;; bbWeight=1 PerfScore 1.00
+RWD00 dd 63E756A3h ; 8.53488e+21

This time, local assertion propagation does not result in gtFoldExprConst folding the expressions in post-order morph:

@@ -518,56 +512,35 @@ Assertion prop in BB01:
Constant Assertion: V00 == 8.53488e+21 index=#01, mask=0000000000000001
[000020] ------------ * CNS_DBL float 8.5348814290707441e+21
-Folding long operator with constant nodes into a constant:- [000021] ------------ * CAST long <- float- [000020] -----+------ \--* CNS_DBL float 8.5348814290707441e+21-Bashed to long constant:- [000021] ------------ * CNS_INT long -0x8000000000000000--Folding operator with constant nodes into a constant:- [000023] ------------ * GT int- [000022] -----+------ +--* CNS_INT long 0x45E23077- [000021] -----+------ \--* CNS_INT long -0x8000000000000000-Bashed to int constant:- [000023] ------------ * CNS_INT int 1--Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- int- [000023] -----+------ \--* CNS_INT int 1-Bashed to long constant:- [000025] ------------ * CNS_INT long 1

Case 3: ConvTest:test1():byte, 16 (44.44% of base):

 G_M30804_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,22 @@ G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- xor ecx, ecx+ vcvttsd2si ecx, dword ptr [reloc @RWD00]+ movsx rsi, cl+ mov ecx, esi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- xor eax, eax- ;; bbWeight=1 PerfScore 4.75+ movsx rax, sil+ ;; bbWeight=1 PerfScore 12.00
G_M30804_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)

Here, VN block takes hold:

 N001 [000002] CNS_DBL -nan(ind) => $140 {DblCns[-nan(ind)]}
VNForCastOper(int) is $41
-N002 [000013] CAST => $42 {IntCns 0x80000000}- VNForCastOper(byte) is $43-N003 [000003] CAST => $44 {IntCns 0}-N004 [000004] LCL_VAR V01 tmp1 d:1 => $44 {IntCns 0}-N005 [000005] ASG => $44 {IntCns 0}+N002 [000013] CAST => $180 {Cast($140, $41)}+ VNForCastOper(byte) is $42+N003 [000003] CAST => $181 {Cast($180, $42)}+N004 [000004] LCL_VAR V01 tmp1 d:1 => $181 {Cast($180, $42)}+N005 [000005] ASG => $181 {Cast($180, $42)}
***** BB01, STMT00001(after)
-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $44-N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $42+N005 ( 10, 12) [000005] -A------R--- * ASG int $181+N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $181+N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $181+N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $180
N001 ( 3, 4) [000002] ------------ \--* CNS_DBL double -nan(ind) $140

This means no constant propagation in assertion prop:

-After constant propagation on [000003]:-STMT00001 (IL 0x00A... ???)-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44- [000016] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N003 ( 1, 3) [000005] -A------R--- * ASG int $44-N002 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N001 ( 1, 1) [000016] ------------ \--* CNS_INT int 0 $44--After constant propagation on [000007]:-STMT00002 (IL ???... ???)-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void- [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44-ReMorphing args for 8.CALL:-argSlots=1, preallocatedArgCount=4, nextSlotNum=4, nextSlotByteOffset=32, outgoingArgSpaceSize=32-ArgTable for 8.CALL after fgMorphArgs:-fgArgTabEntry[arg 0 17.CNS_INT int (By ref), 1 reg: rcx, byteAlignment=8, lateArgInx=0, processed]--optVNAssertionPropCurStmt morphed tree:-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void-N002 ( 1, 1) [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44--After constant propagation on [000015]:-STMT00003 (IL 0x01A... ???)-N003 ( 3, 4) [000009] ------------ * RETURN int $182- [000018] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N002 ( 2, 2) [000009] ------------ * RETURN int $182-N001 ( 1, 1) [000018] ------------ \--* CNS_INT int 0 $44

Case 4: ConvTest:test4():long, -3 (-5.77% of base):

-; Lcl frame size = 40+; Lcl frame size = 32
G_M60593_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,21 @@ G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- mov rcx, 0xD1FFAB1E+ vcvttsd2si rsi, qword ptr [reloc @RWD00]+ mov rcx, rsi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- mov rax, 0xD1FFAB1E- ;; bbWeight=1 PerfScore 4.75+ mov rax, rsi+ ;; bbWeight=1 PerfScore 11.75
G_M60593_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)+-; Total bytes of code 52, prolog size 4, PerfScore 11.45, instruction count 9, allocated bytes for code 52 (MethodHash=1dad134e) for method ConvTest:test4():long+; Total bytes of code 49, prolog size 5, PerfScore 19.65, instruction count 12, allocated bytes for code 49 (MethodHash=1dad134e) for method ConvTest:test4():long

This is another case of no folding in VN:

-N002 [000003] CAST => $180 {LngCns: 0x8000000000000000}-N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {LngCns: 0x8000000000000000}-N004 [000005] ASG => $180 {LngCns: 0x8000000000000000}+N002 [000003] CAST => $180 {Cast($140, $41)}+N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {Cast($140, $41)}+N004 [000005] ASG => $180 {Cast($140, $41)}

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution!

Where they originally were.
@kunalspathak

Copy link
Copy Markdown
Contributor

@SingleAccretion - do you mind taking a look into failures to make sure they are not related to your changes?

@SingleAccretion

SingleAccretion commented Jul 7, 2021

Copy link
Copy Markdown
ContributorAuthor

do you mind taking a look into failures to make sure they are not related to your changes?

@kunalspathak yes of course. Unfortunately the CI is not in the greatest of shapes right now :(.

  1. Build Android x64 Release AllSubsets_Mono_RuntimeTests - log, looks like an infrastructure problem:
[21:26:28] fail: Cannot find a device with app=package:net.dot.JIT_CodeGenBringUpTests, please check that a device is attached
XHarness exit code: 85 (ADB_DEVICE_ENUMERATION_FAILURE)
Test Harness Exitcode is : 85
  1. Build tvOS arm64 Release AllSubsets_Mono - restore failed:
.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : (NETCORE_ENGINEERING_TELEMETRY=Restore) Failed to download package 'Microsoft.Private.Intellisense.5.0.0-preview-20201009.2' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.private.intellisense/5.0.0-preview-20201009.2/microsoft.private.intellisense.5.0.0-preview-20201009.2.nupkg'.
Response status code does not indicate success: 503 (Service Unavailable - TF10216: Azure DevOps services are currently unavailable. Try again later. Activity Id: 84ef9393-5dd8-434a-80b7-f2eb40580efb (DevOps Activity ID: 84EF9393-5DD8-434A-80B7-F2EB40580EFB)).
  1. CoreCLR Product Build OSX arm64 checked - log, another restore failure:
2021-07-06T20:40:41.9426000Z /Users/runner/work/1/s/.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : Failed to download package 'System.Linq.4.1.0-rc2-24027' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/system.linq/4.1.0-rc2-24027/system.linq.4.1.0-rc2-24027.nupkg'. [/Users/runner/work/1/s/src/tests/Common/external/external.csproj] [/Users/runner/work/1/s/src/tests/build.proj]
  1. Libraries Test Run checked coreclr Linux_musl arm Release - log, this time a real test failure:
 Discovering: System.Text.Encoding.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.Text.Encoding.Tests (found 338 of 341 test cases)
Starting: System.Text.Encoding.Tests (parallel test collections = on, max threads = 4)
System.Text.Tests.TranscodingStreamTests.Read_Span(bufferLength: 1) [FAIL]
Assert.Equal() Failure
↓ (pos 4839671)
Expected: ···lmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
Actual: ···lmnopqrstuvwxyzabcdeFghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
↑ (pos 4839671)

This looks like #47444. Seeing as this is a rare failure, maybe we can extract some useful information from this run...?

  1. Libraries Test Run release coreclr Linux x64 Debug - log, another test failure:
System.Net.Http.Functional.Tests.SocketsHttpHandler_HttpClientHandler_ConnectionPooling_Test.Http2_SmallConnectionTimeout_SubsequentRequestUsesDifferentConnection(timeoutPropertyName: "PooledConnectionLifetime") [FAIL]
System.IO.IOException : Unable to write data to the transport connection: Broken pipe.
  1. runtime-dev-innerloop, build #20210706.55, runtime-dev-innerloop, Build OSX x64 release Runtime_Debug, runtime-staging (Build iOSSimulator x64 Release AllSubsets_Mono) - more restore failures.

  2. runtime-staging, many failures - log1, log2, log3 (there are others), not enough space on the device:

Standard Error:
adb: failed to install /datadisks/disk1/work/A1BB08F0/w/B3F70977/e/System.DirectoryServices.Protocols.Tests.apk: Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
  1. runtime-staging, an interpreter test failure - log

  2. runtime-staging, many System.Drawing.Imaging failures (this is Mono on Windows), PNSEs:

 System.Drawing.Imaging.Tests.MetafileTests.Ctor_InvalidEmfTypeIII_ThrowsArgumentException(emfType: 2) [FAIL]
Assert.Throws() Failure
Expected: typeof(System.ArgumentException)
Actual: typeof(System.TypeInitializationException): The type initializer for 'System.Drawing.DrawingCom' threw an exception.
---- System.TypeInitializationException : The type initializer for 'System.Drawing.DrawingCom' threw an exception.

A rich assortment to be sure...

"Real" failures seem to be HTTP one, and the interpreter one, though I find it hard to see how they could be caused by this change (note as well that it passed CI on first run, and no code changes have been committed since).

@kunalspathak
kunalspathak merged commit 527e566 into dotnet:mainJul 7, 2021
@SingleAccretion
SingleAccretion deleted the Disable-Folding-For-Implementation-Defined-Casts branch July 8, 2021 21:21
@ghostghost locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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.

System.Linq.Expressions tests are broken in CI System.Linq.Expressions tests failing on some PRs

4 participants

@SingleAccretion@tannergooding@JulieLeeMSFT@kunalspathak
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Disable folding of implementation-defined casts - #53782

Merged
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts
Jul 7, 2021
Merged

Disable folding of implementation-defined casts#53782
kunalspathak merged 11 commits into
dotnet:mainfrom
SingleAccretion:Disable-Folding-For-Implementation-Defined-Casts

Conversation

@SingleAccretion

@SingleAccretionSingleAccretion commented Jun 6, 2021

Copy link
Copy Markdown
Contributor

With #51440 merged, it is now easy to do the intended second part of that PR and disable folding of all implementation-defined float/double -> integer casts. This is a temporary solution to #47478, but without it I will not be able to move forward with the casts work as a lot of this has so far been masked by the fact that problematic conversions were being morphed into calls and thus not getting folded.

For the diffs, the expectation is that there will be some regressions in coreclr_tests.

Windows x64
Running asm diffs of coreclr_tests.pmi.windows.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49048
Total bytes of diff: 50724
Total bytes of delta: 1676 (3.42% of base)
diff is a regression.
Top method regressions (bytes):
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
95 (30.16% of base) - FloatOvfToInt:TestValuesDoubleInt():int
95 (30.16% of base) - FloatOvfToInt:TestValuesFloatInt():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
59 ( 0.23% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
49 (13.14% of base) - ILGEN_0xe696696:main():int
42 (15.05% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
42 (700.00% of base) - ILGEN_1806854430:main():int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
39 (31.97% of base) - FloatOvfToInt:TestValuesFloatShort():int
38 (19.29% of base) - ILGEN_622380794:main():int
33 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
32 (25.00% of base) - FloatOvfToInt:TestValuesFloatInt():int
32 (25.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (bytes):
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-4 (-5.71% of base) - C:L(float):float
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
Top method regressions (percentages):
42 (700.00% of base) - ILGEN_1806854430:main():int
76 (133.33% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test7():ubyte
16 (44.44% of base) - ConvTest:test2():short
16 (44.44% of base) - ConvTest:test1():byte
116 (39.59% of base) - FloatOvfToInt:TestValuesFloatByte():int
116 (39.59% of base) - FloatOvfToInt:TestValuesDoubleByte():int
14 (38.89% of base) - ConvTest:test8():ushort
14 (38.89% of base) - ConvTest:test8():ushort
17 (37.78% of base) - ILGEN_0x64f58bd0:Method_0x1bb0(int,long,float,int,int):int
110 (37.54% of base) - FloatOvfToInt:TestValuesDoubleShort():int
110 (37.54% of base) - FloatOvfToInt:TestValuesFloatShort():int
72 (36.00% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
41 (33.61% of base) - FloatOvfToInt:TestValuesFloatByte():int
41 (33.61% of base) - FloatOvfToInt:TestValuesDoubleByte():int
39 (31.97% of base) - FloatOvfToInt:TestValuesDoubleShort():int
Top method improvements (percentages):
-3 (-5.77% of base) - ConvTest:test4():long
-3 (-5.77% of base) - ConvTest:test4():long
-4 (-5.71% of base) - C:L(float):float
-22 (-4.14% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-10 (-0.43% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-2 (-0.42% of base) - FloatOvfToInt:TestValuesFloatLong():int
-2 (-0.42% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-1 (-0.35% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.28% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
67 total methods with Code Size differences (9 improved, 58 regressed), 0 unchanged.
Windows x86
Running asm diffs of coreclr_tests.pmi.windows.x86.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 50715
Total bytes of diff: 52539
Total bytes of delta: 1824 (3.60% of base)
diff is a regression.
Top method regressions (bytes):
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleByte():int
106 (27.39% of base) - FloatOvfToInt:TestValuesDoubleShort():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatByte():int
96 (24.81% of base) - FloatOvfToInt:TestValuesFloatShort():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (23.50% of base) - ILGEN_0xe696696:main():int
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
48 (12.66% of base) - DevDiv_590771:ILGEN_METHOD(long,ushort,int,int,ushort,int):byte
47 ( 8.58% of base) - FloatOvfToInt:TestValuesDoubleInt():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
37 ( 6.75% of base) - FloatOvfToInt:TestValuesFloatInt():int
36 (600.00% of base) - ILGEN_1806854430:main():int
36 (13.90% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
34 ( 5.87% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
32 (12.85% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-8 (-5.23% of base) - C:Main():int
-8 (-7.02% of base) - C:L(float):float
Top method regressions (percentages):
36 (600.00% of base) - ILGEN_1806854430:main():int
24 (400.00% of base) - ILGEN_622380794:main():int
94 (142.42% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
81 (78.64% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
21 (75.00% of base) - ILGEN_0xb6f84258:Main():int
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test8():ushort
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test2():short
14 (56.00% of base) - ConvTest:test7():ubyte
14 (56.00% of base) - ConvTest:test1():byte
14 (56.00% of base) - ConvTest:test7():ubyte
3 (37.50% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleShort():int
50 (35.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
78 (31.84% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatShort():int
40 (28.37% of base) - FloatOvfToInt:TestValuesFloatByte():int
94 (27.41% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
Top method improvements (percentages):
-8 (-7.02% of base) - C:L(float):float
-8 (-5.23% of base) - C:Main():int
61 total methods with Code Size differences (2 improved, 59 regressed), 0 unchanged.
Linux x64
Running asm diffs of coreclr_tests.pmi.Linux.x64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 48680
Total bytes of diff: 50694
Total bytes of delta: 2014 (4.14% of base)
diff is a regression.
Top method regressions (bytes):
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
137 (49.46% of base) - FloatOvfToInt:TestValuesDoubleByte():int
131 (47.29% of base) - FloatOvfToInt:TestValuesDoubleShort():int
131 (47.29% of base) - FloatOvfToInt:TestValuesFloatShort():int
115 (37.95% of base) - FloatOvfToInt:TestValuesFloatInt():int
115 (37.95% of base) - FloatOvfToInt:TestValuesDoubleInt():int
78 (36.11% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
60 (15.67% of base) - ILGEN_0xe696696:main():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
53 ( 0.22% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,long,ushort,double,long,long):int
52 (44.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
52 (44.83% of base) - FloatOvfToInt:TestValuesDoubleInt():int
44 (733.33% of base) - ILGEN_1806854430:main():int
42 (16.03% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
38 (16.24% of base) - ILGEN_622380794:main():int
34 (26.77% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
Top method improvements (bytes):
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-8 (-13.11% of base) - C:L(float):float
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
Top method regressions (percentages):
44 (733.33% of base) - ILGEN_1806854430:main():int
74 (132.14% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test1():byte
23 (69.70% of base) - ConvTest:test2():short
23 (69.70% of base) - ConvTest:test2():short
22 (66.67% of base) - ConvTest:test7():ubyte
22 (66.67% of base) - ConvTest:test7():ubyte
21 (63.64% of base) - ConvTest:test8():ushort
21 (63.64% of base) - ConvTest:test8():ushort
18 (54.55% of base) - ConvTest:test9():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test11():int
18 (54.55% of base) - ConvTest:test9():int
58 (52.73% of base) - FloatOvfToInt:TestValuesDoubleByte():int
58 (52.73% of base) - FloatOvfToInt:TestValuesFloatByte():int
56 (50.91% of base) - FloatOvfToInt:TestValuesFloatShort():int
56 (50.91% of base) - FloatOvfToInt:TestValuesDoubleShort():int
3 (50.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
137 (49.46% of base) - FloatOvfToInt:TestValuesFloatByte():int
Top method improvements (percentages):
-8 (-13.11% of base) - C:L(float):float
-22 (-4.03% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesDoubleLong():int
-4 (-0.83% of base) - FloatOvfToInt:TestValuesFloatLong():int
-1 (-0.67% of base) - ILGEN_CLASS:ILGEN_METHOD(ubyte,long,long,ushort):long
-15 (-0.62% of base) - ILGEN_0x537f7b0:Method_0x323f83b5(double,byte,int,short,ubyte,double,short,ushort,double,long,int,long,ushort,long,int):float
-1 (-0.32% of base) - ILGEN_0x19b572e2:Method_0x1a700c9c(double,byte):int
-1 (-0.29% of base) - DevDiv_544985:Test(int,int,int,short,short,short):int
65 total methods with Code Size differences (8 improved, 57 regressed), 2 unchanged.
Linux ARM64
Running asm diffs of coreclr_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 51232
Total bytes of diff: 54080
Total bytes of delta: 2848 (5.56% of base)
diff is a regression.
Top method regressions (bytes):
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (35.53% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
64 (12.40% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (18.52% of base) - FloatOvfToInt:TestValuesFloatLong():int
60 (18.52% of base) - FloatOvfToInt:TestValuesDoubleLong():int
60 (14.15% of base) - ILGEN_0xe696696:main():int
52 (260.00% of base) - ILGEN_1806854430:main():int
44 (26.83% of base) - ILGEN_0x44f8f663:Method_0x2e75f3b4(byte,long,short):int
44 (12.36% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
44 (27.50% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
40 ( 7.75% of base) - ILGEN_0x57cc69ce:Method_0x183df1b1():int
Top method improvements (bytes):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
Top method regressions (percentages):
52 (260.00% of base) - ILGEN_1806854430:main():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleShort():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesDoubleByte():int
192 (84.21% of base) - FloatOvfToInt:TestValuesFloatShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (71.43% of base) - FloatOvfToInt:TestValuesDoubleShort():int
80 (71.43% of base) - FloatOvfToInt:TestValuesFloatShort():int
28 (53.85% of base) - ILGEN_0x77e65197:Main():int
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test1():byte
20 (41.67% of base) - ConvTest:test7():ubyte
20 (41.67% of base) - ConvTest:test8():ushort
20 (41.67% of base) - ConvTest:test2():short
20 (41.67% of base) - ConvTest:test7():ubyte
108 (39.13% of base) - FloatOvfToInt:TestValuesFloatInt():int
108 (39.13% of base) - FloatOvfToInt:TestValuesDoubleInt():int
Top method improvements (percentages):
-8 (-0.83% of base) - ILGEN_0x1bd95bae:Method_0x40637edd(int,byte,short,short,double,float,ubyte,float):short
78 total methods with Code Size differences (1 improved, 77 regressed), 2 unchanged.
Running asm diffs of libraries_tests.pmi.Linux.arm64.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 932
Total bytes of diff: 968
Total bytes of delta: 36 (3.86% of base)
diff is a regression.
Top method regressions (bytes):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
Top method regressions (percentages):
36 ( 5.29% of base) - ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.numeric002.numeric002.Program:MainMethod(System.String[]):int
1 total methods with Code Size differences (0 improved, 1 regressed), 6 unchanged.
Linux ARM
Running asm diffs of coreclr_tests.pmi.Linux.arm.checked.mch
Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 49502
Total bytes of diff: 52992
Total bytes of delta: 3490 (7.05% of base)
diff is a regression.
Top method regressions (bytes):
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleShort():int
198 (43.23% of base) - FloatOvfToInt:TestValuesDoubleByte():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatShort():int
154 (42.78% of base) - FloatOvfToInt:TestValuesFloatByte():int
122 (26.18% of base) - ILGEN_0x1ad7535f:Method_0x2ddbcfb4(short):int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
86 (34.96% of base) - ILGEN_622380794:main():int
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
84 (28.77% of base) - ILGEN_0xc53351bb:Method_0x6cf4(short,byte,int,long,int,long,short,short,ubyte,long,float,ubyte,long,ubyte):float
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
70 ( 0.29% of base) - ILGEN_0x372a9ae6:Method_0xdc6ff1a4(byte,byte,int,int,ushort,double,long,long):int
66 (16.10% of base) - ILGEN_0xe696696:main():int
66 (1,100.00% of base) - ILGEN_1806854430:main():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
66 (12.94% of base) - ILGEN_0x7971e09f:Method_0xd939d2c1(int,int):int
60 (1,000.00% of base) - ILGEN_622380794:main():int
Top method improvements (bytes):
-10 (-11.36% of base) - C:L(float):float
Top method regressions (percentages):
66 (1,100.00% of base) - ILGEN_1806854430:main():int
60 (1,000.00% of base) - ILGEN_622380794:main():int
12 (150.00% of base) - ILGEN_0x34e68074:Method_0x1f01(float):int
44 (146.67% of base) - ILGEN_0xb6f84258:Main():int
96 (106.67% of base) - ILGEN_0x68ef9cc3:Method_0x21f5(long):float
84 (62.69% of base) - ILGEN_0x11c02e62:Method_0x7f2e741b(ubyte,ubyte,float,float,int):int
294 (61.00% of base) - FloatOvfToInt:TestValuesDoubleInt():int
26 (59.09% of base) - ConvTest:test2():short
26 (59.09% of base) - ConvTest:test8():ushort
26 (59.09% of base) - ConvTest:test1():byte
26 (59.09% of base) - ConvTest:test7():ubyte
216 (55.96% of base) - FloatOvfToInt:TestValuesFloatInt():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleByte():int
80 (54.79% of base) - FloatOvfToInt:TestValuesDoubleShort():int
24 (54.55% of base) - ConvTest:test1():byte
24 (54.55% of base) - ConvTest:test2():short
24 (54.55% of base) - ConvTest:test7():ubyte
24 (54.55% of base) - ConvTest:test8():ushort
76 (49.35% of base) - FloatOvfToInt:TestValuesDoubleInt():int
66 (47.83% of base) - FloatOvfToInt:TestValuesFloatInt():int
Top method improvements (percentages):
-10 (-11.36% of base) - C:L(float):float
66 total methods with Code Size differences (1 improved, 65 regressed), 1 unchanged.

Which the replays confirm.

Closes#51346.
Closes#47374.

It is not very effective right now because the "bad" combinations of
types are morphed into helpers too early, but it will be helpful when
we enable folding outside of the importer for those cases too.
It now fails on Windows x86, where many of the
previous similar failures were observed.
@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 6, 2021
@SingleAccretionSingleAccretion changed the title Disable folding for implementation-defined castsDisable folding of implementation-defined castsJun 6, 2021
@SingleAccretion
SingleAccretionforce-pushed the Disable-Folding-For-Implementation-Defined-Casts branch from d47687b to d13b563CompareJune 6, 2021 16:51
@SingleAccretion
SingleAccretion marked this pull request as ready for review June 7, 2021 20:19
@tannergooding

Copy link
Copy Markdown
Member

CC. @dotnet/jit-contrib, community PR

@JulieLeeMSFT

Copy link
Copy Markdown
Member

@kunalspathak PTAL for community PR.

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added some questions. Could you share some of the sample diffs that you see in the test (just to understand how this works underlying). Also, did you check asmdiffs on benchmarks/libraries?

Comment threadsrc/coreclr/jit/valuenum.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Also, did you check asmdiffs on benchmarks/libraries?

Yep, the PR's header is for results of running SPMI over all available collections, so, no diffs outside tests.

Could you share some of the sample diffs that you see in the test (just to understand how this works underlying).

Will recollect the diffs and share the samples.

@SingleAccretion

Copy link
Copy Markdown
ContributorAuthor

Case 1: ILGEN_0x44f8f663:Method_0x2e75f3b4, 76 (133.33% of base):

 G_M64081_IG01:
sub rsp, 40
-+ vzeroupper+
G_M64081_IG02:
movsx rcx, cl
xor ecx, 5
@@ -25,22 +26,41 @@ G_M64081_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, isz
add rcx, rax
mov rax, rcx
shr rax, 32
- jne SHORT G_M64081_IG03+ jne SHORT G_M64081_IG04
xor ecx, ecx
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
- xor ecx, ecx- call CORINFO_HELP_OVERFLOW+ vmovsd xmm0, qword ptr [reloc @RWD00]+ call CORINFO_HELP_DBL2ULNG
; gcr arg pop 0
- int3- ;; bbWeight=1 PerfScore 5.75-G_M64081_IG03: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref+ vxorps xmm0, xmm0+ vcvtsi2ss xmm0, rax+ vcvtss2sd xmm0, xmm0+ call CORINFO_HELP_DBL2ULNG+ ; gcr arg pop 0+ mov rdx, 0xD1FFAB1E+ imul rax, rdx+ mov rdx, 0xD1FFAB1E+ add rax, rdx+ jo SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jg SHORT G_M64081_IG04+ cmp rax, 0xD1FFAB1E+ jl SHORT G_M64081_IG04+ ;; bbWeight=1 PerfScore 23.83+G_M64081_IG03: ; , epilog, nogc, extend+ add rsp, 40+ ret+ ;; bbWeight=1 PerfScore 1.25+G_M64081_IG04: ; gcVars=0000000000000000 {}, gcrefRegs=00000000 {}, byrefRegs=00000000 {}, gcvars, byref
call CORINFO_HELP_OVERFLOW
; gcr arg pop 0
int3
;; bbWeight=0 PerfScore 0.00
+RWD00 dq 4D95800D5C7F3082h ; 5.66058935e+65

Here the early importer folding is blocked, due to the new checks in gtFoldExprConst:

 [ 1] 100 (0x064) nop
[ 1] 101 (0x065) ldc.r8 5.6605893542014790e+65
[ 2] 110 (0x06e) conv.u
-Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- ulong <- double- [000024] ------------ \--* CNS_DBL double 5.6605893542014790e+65-Bashed to long constant:- [000025] ------------ * CNS_INT long 0-
[ 2] 111 (0x06f) conv.r4
-Folding fp operator with constant nodes into a fp constant:- [000026] ------------ * CAST float <- long- [000025] ------------ \--* CNS_INT long 0-Bashed to fp constant:- [000026] ------------ * CNS_DBL float 0.0000000000000000-
[ 2] 112 (0x070) conv.u8
-Folding long operator with constant nodes into a constant:- [000027] ------------ * CAST long <- ulong <- float- [000026] ------------ \--* CNS_DBL float 0.0000000000000000-Bashed to long constant:- [000027] ------------ * CNS_INT long 0-
[ 2] 113 (0x071) mul
[ 1] 114 (0x072) ldc.r4 2281166340096.0000
[ 2] 119 (0x077) ldc.r8 -1.4862075407321284e+46
@@ -475,7 +457,10 @@ STMT00009 (IL ???... ???)
[000095] ---X-------- \--* ADD_ovfl long
[000028] ------------ +--* MUL long
[000018] ------------ | +--* CNS_INT long -0xf925aa1447c2972
- [000027] ------------ | \--* CNS_INT long 0+ [000027] ------------ | \--* CAST long <- ulong <- float+ [000026] ------------ | \--* CAST float <- long+ [000025] ------------ | \--* CAST long <- ulong <- double+ [000024] ------------ | \--* CNS_DBL double 5.6605893542014790e+65
[000094] ---X-------- \--* SUB_ovfl long

Case 2: ILGEN_1806854430:main():int, 42 (700.00% of base):

- mov eax, 100- ;; bbWeight=1 PerfScore 0.25+ vcvttss2si rax, qword ptr [reloc @RWD00]+ cmp rax, 0xD1FFAB1E+ setl dl+ movzx rdx, dl+ movsxd rdx, edx+ cmp rdx, rax+ setg al+ movzx rax, al+ cmp eax, 0xD1FFAB1E+ seta al+ movzx rax, al+ add eax, 100+ ;; bbWeight=1 PerfScore 12.00
G_M58196_IG03: ; , epilog, nogc, extend
ret
;; bbWeight=1 PerfScore 1.00
+RWD00 dd 63E756A3h ; 8.53488e+21

This time, local assertion propagation does not result in gtFoldExprConst folding the expressions in post-order morph:

@@ -518,56 +512,35 @@ Assertion prop in BB01:
Constant Assertion: V00 == 8.53488e+21 index=#01, mask=0000000000000001
[000020] ------------ * CNS_DBL float 8.5348814290707441e+21
-Folding long operator with constant nodes into a constant:- [000021] ------------ * CAST long <- float- [000020] -----+------ \--* CNS_DBL float 8.5348814290707441e+21-Bashed to long constant:- [000021] ------------ * CNS_INT long -0x8000000000000000--Folding operator with constant nodes into a constant:- [000023] ------------ * GT int- [000022] -----+------ +--* CNS_INT long 0x45E23077- [000021] -----+------ \--* CNS_INT long -0x8000000000000000-Bashed to int constant:- [000023] ------------ * CNS_INT int 1--Folding long operator with constant nodes into a constant:- [000025] ------------ * CAST long <- int- [000023] -----+------ \--* CNS_INT int 1-Bashed to long constant:- [000025] ------------ * CNS_INT long 1

Case 3: ConvTest:test1():byte, 16 (44.44% of base):

 G_M30804_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,22 @@ G_M30804_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- xor ecx, ecx+ vcvttsd2si ecx, dword ptr [reloc @RWD00]+ movsx rsi, cl+ mov ecx, esi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- xor eax, eax- ;; bbWeight=1 PerfScore 4.75+ movsx rax, sil+ ;; bbWeight=1 PerfScore 12.00
G_M30804_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)

Here, VN block takes hold:

 N001 [000002] CNS_DBL -nan(ind) => $140 {DblCns[-nan(ind)]}
VNForCastOper(int) is $41
-N002 [000013] CAST => $42 {IntCns 0x80000000}- VNForCastOper(byte) is $43-N003 [000003] CAST => $44 {IntCns 0}-N004 [000004] LCL_VAR V01 tmp1 d:1 => $44 {IntCns 0}-N005 [000005] ASG => $44 {IntCns 0}+N002 [000013] CAST => $180 {Cast($140, $41)}+ VNForCastOper(byte) is $42+N003 [000003] CAST => $181 {Cast($180, $42)}+N004 [000004] LCL_VAR V01 tmp1 d:1 => $181 {Cast($180, $42)}+N005 [000005] ASG => $181 {Cast($180, $42)}
***** BB01, STMT00001(after)
-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $44-N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $42+N005 ( 10, 12) [000005] -A------R--- * ASG int $181+N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $181+N003 ( 10, 12) [000003] ------------ \--* CAST int <- byte <- int $181+N002 ( 9, 10) [000013] ------------ \--* CAST int <- double $180
N001 ( 3, 4) [000002] ------------ \--* CNS_DBL double -nan(ind) $140

This means no constant propagation in assertion prop:

-After constant propagation on [000003]:-STMT00001 (IL 0x00A... ???)-N005 ( 10, 12) [000005] -A------R--- * ASG int $44-N004 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44- [000016] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N003 ( 1, 3) [000005] -A------R--- * ASG int $44-N002 ( 1, 1) [000004] D------N---- +--* LCL_VAR int V01 tmp1 d:1 $44-N001 ( 1, 1) [000016] ------------ \--* CNS_INT int 0 $44--After constant propagation on [000007]:-STMT00002 (IL ???... ???)-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void- [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44-ReMorphing args for 8.CALL:-argSlots=1, preallocatedArgCount=4, nextSlotNum=4, nextSlotByteOffset=32, outgoingArgSpaceSize=32-ArgTable for 8.CALL after fgMorphArgs:-fgArgTabEntry[arg 0 17.CNS_INT int (By ref), 1 reg: rcx, byteAlignment=8, lateArgInx=0, processed]--optVNAssertionPropCurStmt morphed tree:-N003 ( 15, 7) [000008] --CXG------- * CALL void hackishModuleName.hackishMethodName $VN.Void-N002 ( 1, 1) [000017] ------------ arg0 in rcx \--* CNS_INT int 0 $44--After constant propagation on [000015]:-STMT00003 (IL 0x01A... ???)-N003 ( 3, 4) [000009] ------------ * RETURN int $182- [000018] ------------ \--* CNS_INT int 0 $44-optVNAssertionPropCurStmt morphed tree:-N002 ( 2, 2) [000009] ------------ * RETURN int $182-N001 ( 1, 1) [000018] ------------ \--* CNS_INT int 0 $44

Case 4: ConvTest:test4():long, -3 (-5.77% of base):

-; Lcl frame size = 40+; Lcl frame size = 32
G_M60593_IG01: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
- sub rsp, 40- ;; bbWeight=1 PerfScore 0.25+ push rsi+ sub rsp, 32+ ;; bbWeight=1 PerfScore 1.25
G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
mov rcx, 0xD1FFAB1E
mov rcx, gword ptr [rcx]
@@ -21,17 +22,21 @@ G_M60593_IG02: ; gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
call hackishModuleName:hackishMethodName()
; gcrRegs -[rcx]
; gcr arg pop 0
- mov rcx, 0xD1FFAB1E+ vcvttsd2si rsi, qword ptr [reloc @RWD00]+ mov rcx, rsi
call hackishModuleName:hackishMethodName()
; gcr arg pop 0
- mov rax, 0xD1FFAB1E- ;; bbWeight=1 PerfScore 4.75+ mov rax, rsi+ ;; bbWeight=1 PerfScore 11.75
G_M60593_IG03: ; , epilog, nogc, extend
- add rsp, 40+ add rsp, 32+ pop rsi
ret
- ;; bbWeight=1 PerfScore 1.25+ ;; bbWeight=1 PerfScore 1.75+RWD00 dq FFF8000000000000h ; -nan(ind)+-; Total bytes of code 52, prolog size 4, PerfScore 11.45, instruction count 9, allocated bytes for code 52 (MethodHash=1dad134e) for method ConvTest:test4():long+; Total bytes of code 49, prolog size 5, PerfScore 19.65, instruction count 12, allocated bytes for code 49 (MethodHash=1dad134e) for method ConvTest:test4():long

This is another case of no folding in VN:

-N002 [000003] CAST => $180 {LngCns: 0x8000000000000000}-N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {LngCns: 0x8000000000000000}-N004 [000005] ASG => $180 {LngCns: 0x8000000000000000}+N002 [000003] CAST => $180 {Cast($140, $41)}+N003 [000004] LCL_VAR V01 tmp1 d:1 => $180 {Cast($140, $41)}+N004 [000005] ASG => $180 {Cast($140, $41)}

@kunalspathakkunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution!

Where they originally were.
@kunalspathak

Copy link
Copy Markdown
Contributor

@SingleAccretion - do you mind taking a look into failures to make sure they are not related to your changes?

@SingleAccretion

SingleAccretion commented Jul 7, 2021

Copy link
Copy Markdown
ContributorAuthor

do you mind taking a look into failures to make sure they are not related to your changes?

@kunalspathak yes of course. Unfortunately the CI is not in the greatest of shapes right now :(.

  1. Build Android x64 Release AllSubsets_Mono_RuntimeTests - log, looks like an infrastructure problem:
[21:26:28] fail: Cannot find a device with app=package:net.dot.JIT_CodeGenBringUpTests, please check that a device is attached
XHarness exit code: 85 (ADB_DEVICE_ENUMERATION_FAILURE)
Test Harness Exitcode is : 85
  1. Build tvOS arm64 Release AllSubsets_Mono - restore failed:
.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : (NETCORE_ENGINEERING_TELEMETRY=Restore) Failed to download package 'Microsoft.Private.Intellisense.5.0.0-preview-20201009.2' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.private.intellisense/5.0.0-preview-20201009.2/microsoft.private.intellisense.5.0.0-preview-20201009.2.nupkg'.
Response status code does not indicate success: 503 (Service Unavailable - TF10216: Azure DevOps services are currently unavailable. Try again later. Activity Id: 84ef9393-5dd8-434a-80b7-f2eb40580efb (DevOps Activity ID: 84EF9393-5DD8-434A-80B7-F2EB40580EFB)).
  1. CoreCLR Product Build OSX arm64 checked - log, another restore failure:
2021-07-06T20:40:41.9426000Z /Users/runner/work/1/s/.dotnet/sdk/6.0.100-preview.4.21255.9/NuGet.RestoreEx.targets(19,5): error : Failed to download package 'System.Linq.4.1.0-rc2-24027' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/system.linq/4.1.0-rc2-24027/system.linq.4.1.0-rc2-24027.nupkg'. [/Users/runner/work/1/s/src/tests/Common/external/external.csproj] [/Users/runner/work/1/s/src/tests/build.proj]
  1. Libraries Test Run checked coreclr Linux_musl arm Release - log, this time a real test failure:
 Discovering: System.Text.Encoding.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.Text.Encoding.Tests (found 338 of 341 test cases)
Starting: System.Text.Encoding.Tests (parallel test collections = on, max threads = 4)
System.Text.Tests.TranscodingStreamTests.Read_Span(bufferLength: 1) [FAIL]
Assert.Equal() Failure
↓ (pos 4839671)
Expected: ···lmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
Actual: ···lmnopqrstuvwxyzabcdeFghijklmnopqrstuvwxyzabcdefghijklmnopqrst···
↑ (pos 4839671)

This looks like #47444. Seeing as this is a rare failure, maybe we can extract some useful information from this run...?

  1. Libraries Test Run release coreclr Linux x64 Debug - log, another test failure:
System.Net.Http.Functional.Tests.SocketsHttpHandler_HttpClientHandler_ConnectionPooling_Test.Http2_SmallConnectionTimeout_SubsequentRequestUsesDifferentConnection(timeoutPropertyName: "PooledConnectionLifetime") [FAIL]
System.IO.IOException : Unable to write data to the transport connection: Broken pipe.
  1. runtime-dev-innerloop, build #20210706.55, runtime-dev-innerloop, Build OSX x64 release Runtime_Debug, runtime-staging (Build iOSSimulator x64 Release AllSubsets_Mono) - more restore failures.

  2. runtime-staging, many failures - log1, log2, log3 (there are others), not enough space on the device:

Standard Error:
adb: failed to install /datadisks/disk1/work/A1BB08F0/w/B3F70977/e/System.DirectoryServices.Protocols.Tests.apk: Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
  1. runtime-staging, an interpreter test failure - log

  2. runtime-staging, many System.Drawing.Imaging failures (this is Mono on Windows), PNSEs:

 System.Drawing.Imaging.Tests.MetafileTests.Ctor_InvalidEmfTypeIII_ThrowsArgumentException(emfType: 2) [FAIL]
Assert.Throws() Failure
Expected: typeof(System.ArgumentException)
Actual: typeof(System.TypeInitializationException): The type initializer for 'System.Drawing.DrawingCom' threw an exception.
---- System.TypeInitializationException : The type initializer for 'System.Drawing.DrawingCom' threw an exception.

A rich assortment to be sure...

"Real" failures seem to be HTTP one, and the interpreter one, though I find it hard to see how they could be caused by this change (note as well that it passed CI on first run, and no code changes have been committed since).

@kunalspathak
kunalspathak merged commit 527e566 into dotnet:mainJul 7, 2021
@SingleAccretion
SingleAccretion deleted the Disable-Folding-For-Implementation-Defined-Casts branch July 8, 2021 21:21
@ghostghost locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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.

System.Linq.Expressions tests are broken in CI System.Linq.Expressions tests failing on some PRs

4 participants

@SingleAccretion@tannergooding@JulieLeeMSFT@kunalspathak