{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/73760980","id":73760980,"diff_hunk":"@@ -435,3 +453,203 @@ GenTreePtr Compiler::optPropGetValueRec(unsigned lclNum, unsigned ssaNum, optPro\n \n     return value;\n }\n+\n+//----------------------------------------------------------------\n+// optFoldNullChecks: Try to find a GT_NULLCHECK node that can be folded into the GT_INDIR node.\n+//\n+// Arguments:\n+//    tree           - The input GT_INDIR tree.\n+//\n+\n+void Compiler::optFoldNullCheck(GenTreePtr tree)\n+{\n+    //\n+    // Check for a pattern like this:\n+    //\n+    //                         =\n+    //                       /   \\\n+    //                      x    comma\n+    //                           /   \\\n+    //                     nullcheck  +\n+    //                         |     / \\\n+    //                         y    y  const\n+    //\n+    //\n+    //        some trees in the same basic block with no unsafe side effects here\n+    //\n+    //                           indir\n+    //                             |\n+    //                             x\n+    //\n+    // where the const is suitably small\n+    // and transform it into\n+    //\n+    //                         =\n+    //                       /   \\\n+    //                      x     +\n+    //                           / \\\n+    //                          y  const\n+    //\n+    //\n+    //              some trees with no unsafe side effects here\n+    //","path":"src/jit/earlyprop.cpp","position":173,"original_position":173,"commit_id":"41c7a4cd082fe66d57a9aa8bafba654abbdb99c2","original_commit_id":"41c7a4cd082fe66d57a9aa8bafba654abbdb99c2","user":{"login":"briansull","id":11621884,"avatar_url":"https://avatars.githubusercontent.com/u/11621884?v=3","gravatar_id":"","url":"https://api.github.com/users/briansull","html_url":"https://github.com/briansull","followers_url":"https://api.github.com/users/briansull/followers","following_url":"https://api.github.com/users/briansull/following{/other_user}","gists_url":"https://api.github.com/users/briansull/gists{/gist_id}","starred_url":"https://api.github.com/users/briansull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briansull/subscriptions","organizations_url":"https://api.github.com/users/briansull/orgs","repos_url":"https://api.github.com/users/briansull/repos","events_url":"https://api.github.com/users/briansull/events{/privacy}","received_events_url":"https://api.github.com/users/briansull/received_events","type":"User","site_admin":false},"body":"The indentation of this line \"some trees ...\" should be the same as the previous occurrence.","created_at":"2016-08-05T21:18:50Z","updated_at":"2016-08-05T21:18:50Z","html_url":"https://github.com/dotnet/coreclr/pull/6631#discussion_r73760980","pull_request_url":"https://api.github.com/repos/dotnet/coreclr/pulls/6631","_links":{"self":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/73760980"},"html":{"href":"https://github.com/dotnet/coreclr/pull/6631#discussion_r73760980"},"pull_request":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/6631"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/6631","id":80301053,"html_url":"https://github.com/dotnet/coreclr/pull/6631","diff_url":"https://github.com/dotnet/coreclr/pull/6631.diff","patch_url":"https://github.com/dotnet/coreclr/pull/6631.patch","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/6631","number":6631,"state":"open","locked":false,"title":"Null check folding.","user":{"login":"erozenfeld","id":10624223,"avatar_url":"https://avatars.githubusercontent.com/u/10624223?v=3","gravatar_id":"","url":"https://api.github.com/users/erozenfeld","html_url":"https://github.com/erozenfeld","followers_url":"https://api.github.com/users/erozenfeld/followers","following_url":"https://api.github.com/users/erozenfeld/following{/other_user}","gists_url":"https://api.github.com/users/erozenfeld/gists{/gist_id}","starred_url":"https://api.github.com/users/erozenfeld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erozenfeld/subscriptions","organizations_url":"https://api.github.com/users/erozenfeld/orgs","repos_url":"https://api.github.com/users/erozenfeld/repos","events_url":"https://api.github.com/users/erozenfeld/events{/privacy}","received_events_url":"https://api.github.com/users/erozenfeld/received_events","type":"User","site_admin":false},"body":"1. Added a null check folding optimization to early prop. The optimization tries to fold\r\nGT_NULLCHECK(y) nodes  into GT_IND(x) nodes where x=y+const\r\nin the same block (where const is sufficiently small). The algorithm uses SSA use-def info\r\nto go from x to its def and then tries to match the pattern x = COMMA(NULLCHECK(y), ADD(y, const))).\r\nIf such a pattern is found, the algorithm checks the trees and statements that are between the use\r\nand the def in execution order to see if they have unsafe side effects: calls, exception sources, and\r\nassignments (all assignment if we are in a try and assignments to global memory if we are not).\r\nIf there are no nodes with unsafe side effects, the null check is removed.\r\n\r\n2. Made several improvements to null check elimination in assertion propagation.\r\n  * Added a new kind for op1: O1K_VALUE_NUMBER\r\n  * Non-null assertions can now be made about arbitrary value numbers, not just locals\r\n..* Fixed code that was trying to find a ref given a byref: the code now handles an arbitrary number of\r\n    offsets and checks whether the total offsetof is small enough.\r\n * Added similar code that tries to find a ref VN given a byref VN\r\n\r\nThis addresses part of the suboptimal code generated for #1226: null check is no longer emitted.\r\n\r\nCorrectness: ran full desktop and CoreCLR testing.\r\n\r\nThroughput: no measurable throughput impact (verified by running internal CQNgenTP several times).\r\n\r\nCode size in CoreCLR:\r\n\r\nFramework assemblies:\r\n\r\nTotal bytes of diff: -805 (-0.01 % of base)\r\n    diff is an improvement.\r\nTotal byte diff includes 0 bytes from reconciling methods\r\n        Base had    0 unique methods,        0 unique bytes\r\n        Diff had    0 unique methods,        0 unique bytes\r\nTop file improvements by size (bytes):\r\n        -352 : System.Private.CoreLib.dasm (-0.01 % of base)\r\n        -306 : Microsoft.CodeAnalysis.CSharp.dasm (-0.01 % of base)\r\n         -58 : Microsoft.CodeAnalysis.dasm (-0.01 % of base)\r\n         -48 : System.Numerics.Vectors.dasm (-0.08 % of base)\r\n         -14 : System.Xml.XmlDocument.dasm (-0.01 % of base)\r\n7 total files with size differences.\r\nTop method improvements by size (bytes):\r\n         -30 : System.Numerics.Vectors.dasm - System.Numerics.Matrix4x4:ToString():ref:this\r\n         -30 : System.Private.CoreLib.dasm - System.DateTimeParse:ParseByFormat(byref,byref,byref,ref,byref):bool\r\n         -24 : Microsoft.CodeAnalysis.CSharp.dasm - <GetMethodsToEmit>d__68:MoveNext():bool:this\r\n         -18 : System.Private.CoreLib.dasm - System.DateTimeParse:Lex(int,byref,byref,byref,byref,byref,int):bool\r\n         -18 : System.Private.CoreLib.dasm - System.DateTimeParse:ProcessDateTimeSuffix(byref,byref,byref):bool\r\n243 total methods with size differences.\r\n\r\nJIT Code quality benchmarks in CoreCLR:\r\n\r\nTotal bytes of diff: -29 (-0.01 % of base)\r\n    diff is an improvement.\r\nTotal byte diff includes 0 bytes from reconciling methods\r\n        Base had    0 unique methods,        0 unique bytes\r\n        Diff had    0 unique methods,        0 unique bytes\r\nTop file improvements by size (bytes):\r\n         -25 : Bytemark\\Bytemark\\Bytemark.dasm (-0.03 % of base)\r\n          -4 : BenchmarksGame\\pidigits\\pi-digits\\pi-digits.dasm (-0.21 % of base)\r\n2 total files with size differences.\r\nTop method improvements by size (bytes):\r\n          -9 : Bytemark\\Bytemark\\Bytemark.dasm - AssignJagged:second_assignments(ref,ref)\r\n          -6 : Bytemark\\Bytemark\\Bytemark.dasm - EMFloat:MultiplyInternalFPF(byref,byref,byref)\r\n          -4 : Bytemark\\Bytemark\\Bytemark.dasm - EMFloat:AddSubInternalFPF(ubyte,byref,byref,byref)\r\n          -2 : Bytemark\\Bytemark\\Bytemark.dasm - EMFloat:denormalize(byref,int)\r\n          -2 : Bytemark\\Bytemark\\Bytemark.dasm - EMFloat:DivideInternalFPF(byref,byref,byref)\r\n8 total methods with size differences.\r\n\r\nIn internal SPMI:\r\n\r\n3915 methods with diffs, almost everything -- code size improvements\r\n13,715 bytes code size reduction overall 0.51% on affected methods\r\n\r\nCQ_Perf: 85 methods with diffs, 84 code size improvements, no regressions\r\nBenchmarks with code size diffs:\r\nRoslyn 59\r\nTrueTypeBench 19\r\nmono-pi-digits 2\r\nmono-chameneos-redux 2\r\nByteMark\\assign_jagged 1\r\nJson_Serialize 1\r\nSharpChess 1\r\nBenchI\\mulmtx 1\r\n\r\nInternal CQPerf didn't report any runtime wins for these benchmarks.","created_at":"2016-08-05T20:17:37Z","updated_at":"2016-08-05T21:18:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2759f9580d320f8346c9c5a8f4a55dbb0b6506c1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/coreclr/pulls/6631/commits","review_comments_url":"https://api.github.com/repos/dotnet/coreclr/pulls/6631/comments","review_comment_url":"https://api.github.com/repos/dotnet/coreclr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/6631/comments","statuses_url":"https://api.github.com/repos/dotnet/coreclr/statuses/41c7a4cd082fe66d57a9aa8bafba654abbdb99c2","head":{"label":"erozenfeld:NullCheckFolding","ref":"NullCheckFolding","sha":"41c7a4cd082fe66d57a9aa8bafba654abbdb99c2","user":{"login":"erozenfeld","id":10624223,"avatar_url":"https://avatars.githubusercontent.com/u/10624223?v=3","gravatar_id":"","url":"https://api.github.com/users/erozenfeld","html_url":"https://github.com/erozenfeld","followers_url":"https://api.github.com/users/erozenfeld/followers","following_url":"https://api.github.com/users/erozenfeld/following{/other_user}","gists_url":"https://api.github.com/users/erozenfeld/gists{/gist_id}","starred_url":"https://api.github.com/users/erozenfeld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erozenfeld/subscriptions","organizations_url":"https://api.github.com/users/erozenfeld/orgs","repos_url":"https://api.github.com/users/erozenfeld/repos","events_url":"https://api.github.com/users/erozenfeld/events{/privacy}","received_events_url":"https://api.github.com/users/erozenfeld/received_events","type":"User","site_admin":false},"repo":{"id":37150968,"name":"coreclr","full_name":"erozenfeld/coreclr","owner":{"login":"erozenfeld","id":10624223,"avatar_url":"https://avatars.githubusercontent.com/u/10624223?v=3","gravatar_id":"","url":"https://api.github.com/users/erozenfeld","html_url":"https://github.com/erozenfeld","followers_url":"https://api.github.com/users/erozenfeld/followers","following_url":"https://api.github.com/users/erozenfeld/following{/other_user}","gists_url":"https://api.github.com/users/erozenfeld/gists{/gist_id}","starred_url":"https://api.github.com/users/erozenfeld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erozenfeld/subscriptions","organizations_url":"https://api.github.com/users/erozenfeld/orgs","repos_url":"https://api.github.com/users/erozenfeld/repos","events_url":"https://api.github.com/users/erozenfeld/events{/privacy}","received_events_url":"https://api.github.com/users/erozenfeld/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/erozenfeld/coreclr","description":"This repo contains the .NET Core runtime, called CoreCLR, and the base library, called mscorlib. It includes the garbage collector, JIT compiler, base .NET data types and many low-level classes.","fork":true,"url":"https://api.github.com/repos/erozenfeld/coreclr","forks_url":"https://api.github.com/repos/erozenfeld/coreclr/forks","keys_url":"https://api.github.com/repos/erozenfeld/coreclr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/erozenfeld/coreclr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/erozenfeld/coreclr/teams","hooks_url":"https://api.github.com/repos/erozenfeld/coreclr/hooks","issue_events_url":"https://api.github.com/repos/erozenfeld/coreclr/issues/events{/number}","events_url":"https://api.github.com/repos/erozenfeld/coreclr/events","assignees_url":"https://api.github.com/repos/erozenfeld/coreclr/assignees{/user}","branches_url":"https://api.github.com/repos/erozenfeld/coreclr/branches{/branch}","tags_url":"https://api.github.com/repos/erozenfeld/coreclr/tags","blobs_url":"https://api.github.com/repos/erozenfeld/coreclr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/erozenfeld/coreclr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/erozenfeld/coreclr/git/refs{/sha}","trees_url":"https://api.github.com/repos/erozenfeld/coreclr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/erozenfeld/coreclr/statuses/{sha}","languages_url":"https://api.github.com/repos/erozenfeld/coreclr/languages","stargazers_url":"https://api.github.com/repos/erozenfeld/coreclr/stargazers","contributors_url":"https://api.github.com/repos/erozenfeld/coreclr/contributors","subscribers_url":"https://api.github.com/repos/erozenfeld/coreclr/subscribers","subscription_url":"https://api.github.com/repos/erozenfeld/coreclr/subscription","commits_url":"https://api.github.com/repos/erozenfeld/coreclr/commits{/sha}","git_commits_url":"https://api.github.com/repos/erozenfeld/coreclr/git/commits{/sha}","comments_url":"https://api.github.com/repos/erozenfeld/coreclr/comments{/number}","issue_comment_url":"https://api.github.com/repos/erozenfeld/coreclr/issues/comments{/number}","contents_url":"https://api.github.com/repos/erozenfeld/coreclr/contents/{+path}","compare_url":"https://api.github.com/repos/erozenfeld/coreclr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/erozenfeld/coreclr/merges","archive_url":"https://api.github.com/repos/erozenfeld/coreclr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/erozenfeld/coreclr/downloads","issues_url":"https://api.github.com/repos/erozenfeld/coreclr/issues{/number}","pulls_url":"https://api.github.com/repos/erozenfeld/coreclr/pulls{/number}","milestones_url":"https://api.github.com/repos/erozenfeld/coreclr/milestones{/number}","notifications_url":"https://api.github.com/repos/erozenfeld/coreclr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/erozenfeld/coreclr/labels{/name}","releases_url":"https://api.github.com/repos/erozenfeld/coreclr/releases{/id}","deployments_url":"https://api.github.com/repos/erozenfeld/coreclr/deployments","created_at":"2015-06-09T18:39:42Z","updated_at":"2016-06-02T01:04:42Z","pushed_at":"2016-08-05T20:15:41Z","git_url":"git://github.com/erozenfeld/coreclr.git","ssh_url":"git@github.com:erozenfeld/coreclr.git","clone_url":"https://github.com/erozenfeld/coreclr.git","svn_url":"https://github.com/erozenfeld/coreclr","homepage":"","size":93811,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"409fe37d3463210d74e0513b9c7041f8c0a924a4","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":30092893,"name":"coreclr","full_name":"dotnet/coreclr","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/coreclr","description":"This repo contains the .NET Core runtime, called CoreCLR, and the base library, called mscorlib. It includes the garbage collector, JIT compiler, base .NET data types and many low-level classes.","fork":false,"url":"https://api.github.com/repos/dotnet/coreclr","forks_url":"https://api.github.com/repos/dotnet/coreclr/forks","keys_url":"https://api.github.com/repos/dotnet/coreclr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/coreclr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/coreclr/teams","hooks_url":"https://api.github.com/repos/dotnet/coreclr/hooks","issue_events_url":"https://api.github.com/repos/dotnet/coreclr/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/coreclr/events","assignees_url":"https://api.github.com/repos/dotnet/coreclr/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/coreclr/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/coreclr/tags","blobs_url":"https://api.github.com/repos/dotnet/coreclr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/coreclr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/coreclr/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/coreclr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/coreclr/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/coreclr/languages","stargazers_url":"https://api.github.com/repos/dotnet/coreclr/stargazers","contributors_url":"https://api.github.com/repos/dotnet/coreclr/contributors","subscribers_url":"https://api.github.com/repos/dotnet/coreclr/subscribers","subscription_url":"https://api.github.com/repos/dotnet/coreclr/subscription","commits_url":"https://api.github.com/repos/dotnet/coreclr/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/coreclr/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/coreclr/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/coreclr/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/coreclr/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/coreclr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/coreclr/merges","archive_url":"https://api.github.com/repos/dotnet/coreclr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/coreclr/downloads","issues_url":"https://api.github.com/repos/dotnet/coreclr/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/coreclr/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/coreclr/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/coreclr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/coreclr/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/coreclr/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/coreclr/deployments","created_at":"2015-01-30T22:10:02Z","updated_at":"2016-08-05T18:30:18Z","pushed_at":"2016-08-05T21:06:19Z","git_url":"git://github.com/dotnet/coreclr.git","ssh_url":"git@github.com:dotnet/coreclr.git","clone_url":"https://github.com/dotnet/coreclr.git","svn_url":"https://github.com/dotnet/coreclr","homepage":"https://docs.microsoft.com/dotnet/","size":106008,"stargazers_count":6761,"watchers_count":6761,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1591,"mirror_url":null,"open_issues_count":914,"forks":1591,"open_issues":914,"watchers":6761,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/6631"},"html":{"href":"https://github.com/dotnet/coreclr/pull/6631"},"issue":{"href":"https://api.github.com/repos/dotnet/coreclr/issues/6631"},"comments":{"href":"https://api.github.com/repos/dotnet/coreclr/issues/6631/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/6631/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/6631/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/coreclr/statuses/41c7a4cd082fe66d57a9aa8bafba654abbdb99c2"}}}}
{"actor":{"display_login":"briansull"}}