From 0711163b88aad01cf4b2ed442b7512e7e1a7ef31 Mon Sep 17 00:00:00 2001 From: Chris McKinsey Date: Sat, 28 Mar 2015 11:21:51 -0700 Subject: Change null constant type to be TYP_REF for isinst nullcheck expansion In the importer when inlining the fast expansion sequence for isinst/castclass, the code was typing the constant 0 source of the compare with TYP_I_IMPL instead of TYP_REF. Not only does this create an inconsistently typed compare but it causes value-numbering of the same constants with different types to not be equal. This blocks later assertion propagation that propagates null-checks and prevents many cases from being eliminated. This change changes the type of the constant gtNode to be TYP_REF. With this change there are many good diffs in the frameworks and other assemblies. Ran testing in desktop branch including SuperPMI asm diffs. Asm diffs show hundreds of methods with improvements in framework , Roslyn, and other internal assemblies. 1% code size reduction in the methods that have changes. All diffs are elimination of redundant null-checks. --- src/jit/importer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/jit') diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index 652231085f..d55710400b 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -8178,7 +8178,7 @@ GenTreePtr Compiler::impCastClassOrIsInstToTree(GenTreePtr op1, GenTreePtr op2, // op1Copy CNS_INT // null // - condNull = gtNewOperNode(GT_EQ, TYP_INT, gtClone(op1), gtNewIconNode(0, TYP_I_IMPL)); + condNull = gtNewOperNode(GT_EQ, TYP_INT, gtClone(op1), gtNewIconNode(0, TYP_REF)); // // expand the true and false trees for the condMT -- cgit v1.2.3