{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/7434","repository_url":"https://api.github.com/repos/dotnet/coreclr","labels_url":"https://api.github.com/repos/dotnet/coreclr/issues/7434/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/7434/comments","events_url":"https://api.github.com/repos/dotnet/coreclr/issues/7434/events","html_url":"https://github.com/dotnet/coreclr/issues/7434","id":180415559,"number":7434,"title":"RyuJIT: Eliminate unnecessary copies after struct fields are p-indep promoted in Frame:CreateResponseHeader(ref,bool):this","user":{"login":"sivarv","id":11184808,"avatar_url":"https://avatars.githubusercontent.com/u/11184808?v=3","gravatar_id":"","url":"https://api.github.com/users/sivarv","html_url":"https://github.com/sivarv","followers_url":"https://api.github.com/users/sivarv/followers","following_url":"https://api.github.com/users/sivarv/following{/other_user}","gists_url":"https://api.github.com/users/sivarv/gists{/gist_id}","starred_url":"https://api.github.com/users/sivarv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sivarv/subscriptions","organizations_url":"https://api.github.com/users/sivarv/orgs","repos_url":"https://api.github.com/users/sivarv/repos","events_url":"https://api.github.com/users/sivarv/events{/privacy}","received_events_url":"https://api.github.com/users/sivarv/received_events","type":"User","site_admin":false},"labels":[{"id":196940911,"url":"https://api.github.com/repos/dotnet/coreclr/labels/CodeGen","name":"CodeGen","color":"d4c5f9","default":false},{"id":190283555,"url":"https://api.github.com/repos/dotnet/coreclr/labels/optimization","name":"optimization","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":{"login":"JosephTremoulet","id":10655216,"avatar_url":"https://avatars.githubusercontent.com/u/10655216?v=3","gravatar_id":"","url":"https://api.github.com/users/JosephTremoulet","html_url":"https://github.com/JosephTremoulet","followers_url":"https://api.github.com/users/JosephTremoulet/followers","following_url":"https://api.github.com/users/JosephTremoulet/following{/other_user}","gists_url":"https://api.github.com/users/JosephTremoulet/gists{/gist_id}","starred_url":"https://api.github.com/users/JosephTremoulet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JosephTremoulet/subscriptions","organizations_url":"https://api.github.com/users/JosephTremoulet/orgs","repos_url":"https://api.github.com/users/JosephTremoulet/repos","events_url":"https://api.github.com/users/JosephTremoulet/events{/privacy}","received_events_url":"https://api.github.com/users/JosephTremoulet/received_events","type":"User","site_admin":false},"assignees":[{"login":"JosephTremoulet","id":10655216,"avatar_url":"https://avatars.githubusercontent.com/u/10655216?v=3","gravatar_id":"","url":"https://api.github.com/users/JosephTremoulet","html_url":"https://github.com/JosephTremoulet","followers_url":"https://api.github.com/users/JosephTremoulet/followers","following_url":"https://api.github.com/users/JosephTremoulet/following{/other_user}","gists_url":"https://api.github.com/users/JosephTremoulet/gists{/gist_id}","starred_url":"https://api.github.com/users/JosephTremoulet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JosephTremoulet/subscriptions","organizations_url":"https://api.github.com/users/JosephTremoulet/orgs","repos_url":"https://api.github.com/users/JosephTremoulet/repos","events_url":"https://api.github.com/users/JosephTremoulet/events{/privacy}","received_events_url":"https://api.github.com/users/JosephTremoulet/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/dotnet/coreclr/milestones/5","html_url":"https://github.com/dotnet/coreclr/milestones/Future","labels_url":"https://api.github.com/repos/dotnet/coreclr/milestones/5/labels","id":1328081,"number":5,"title":"Future","description":"Milestone tracking the issues that have been triaged for after 1.0.0-rtm","creator":{"login":"joshfree","id":1302850,"avatar_url":"https://avatars.githubusercontent.com/u/1302850?v=3","gravatar_id":"","url":"https://api.github.com/users/joshfree","html_url":"https://github.com/joshfree","followers_url":"https://api.github.com/users/joshfree/followers","following_url":"https://api.github.com/users/joshfree/following{/other_user}","gists_url":"https://api.github.com/users/joshfree/gists{/gist_id}","starred_url":"https://api.github.com/users/joshfree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshfree/subscriptions","organizations_url":"https://api.github.com/users/joshfree/orgs","repos_url":"https://api.github.com/users/joshfree/repos","events_url":"https://api.github.com/users/joshfree/events{/privacy}","received_events_url":"https://api.github.com/users/joshfree/received_events","type":"User","site_admin":false},"open_issues":625,"closed_issues":339,"state":"open","created_at":"2015-09-29T00:26:07Z","updated_at":"2016-10-28T18:46:16Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-09-30T22:30:44Z","updated_at":"2016-10-28T20:55:36Z","closed_at":null,"body":"Here is the IR and code generated:\r\n\r\n\r\n```\r\nN245 (  1,  1) [000466] ------------      t466 =    const     ref    null REG rcx $VN.Null\r\n\r\n                                                 /--*  t466   ref    \r\nN247 (  5,  4) [000468] DA--G-------             *  st.lclVar ref    V57 tmp48        d:3 rbx REG rbx RV\r\n\r\nN249 (  3,  2) [000987] -------N----      t987 =    lclVar    ref    V56 tmp47        u:3 rdx (last use) REG rdx RV $2aa\r\n\r\n                                                 /--*  t987   ref    \r\nN251 (  7,  5) [000988] DA----------             *  st.lclVar ref    V54 tmp45        d:3 rdx REG rdx RV\r\n\r\nN253 (  3,  2) [000990] -------N----      t990 =    lclVar    ref    V57 tmp48        u:3 rbx (last use) REG rbx RV $VN.Null\r\n\r\n                                                 /--*  t990   ref    \r\nN255 (  7,  5) [000991] DA----------             *  st.lclVar ref    V55 tmp46        d:3 rcx REG rcx RV\r\n\r\nN257 (  3,  2) [000994] -------N----      t994 =    lclVar    ref    V54 tmp45        u:3 rdx (last use) REG rdx RV $2aa\r\n\r\n                                                 /--*  t994   ref    \r\nN259 (  7,  5) [000995] DA----------             *  st.lclVar ref    V58 tmp49        d:3 rdx REG rdx RV\r\n\r\nN261 (  3,  2) [000997] -------N----      t997 =    lclVar    ref    V55 tmp46        u:3 rcx (last use) REG rcx RV $VN.Null\r\n\r\n                                                 /--*  t997   ref    \r\nN263 (  7,  5) [000998] DA----------             *  st.lclVar ref    V59 tmp50        d:3 rbx REG rbx RV\r\n\r\n```\r\n\r\n ```\r\nHere are the assignments:\r\nV56 = indir(some const addr)\r\nV57 = null   ; xor rbx, rbx\r\nV54 = V56   ; both get rdx and hence no mov gets generated. V56 last use here\r\nV55 = V57  ;  mov rcx, rbx ; V57 last use here\r\nV58 = V54  ;  both get rdx and hence no mov gets generated. V54 last use here. V58 is used later\r\nV59 = V55  ;  mov rbx, rcx ; V59 was assigned rbx. V59 is used later\r\n\r\n\r\n33DB                 xor      rbx, rbx\r\n488BCB               mov      rcx, rbx\r\n488BD9               mov      rbx, rcx\r\n48B9385618DF1C010000 mov      rcx, 0x11CDF185638\r\n```\r\n\r\nAs you can see we have two separate chains of assignment\r\n\r\n1)  indir(some const addr) --> V56 --> V54  --> V58\r\n2)  null --> V57 --> V55 --> V59\r\n\r\nLSRA got its preferencing right for first chain and there were no redundant moves.\r\nIn the second chain, it didn't get preferencing right and lead to redundant moves.\r\n\r\nIf RyuJIT did copy prop we could reduce both chains of assignment to\r\n\r\ni) V58 = indir(some constant addr)\r\nii) V59 = null\r\n\r\nIn general it is good to avoid these redundant assignments by copy propagation.  Prior to rationalization, these assignments were part of a GT_COMMA  tree and that could be the reason why copy propagation might have not taken palce?\r\n\r\n```\r\n***** BB10, stmt 21\r\n     (  5,  4) [000469] ------------             *  stmtExpr  void  (IL 0x085...  ???)\r\nN001 (  1,  1) [000466] ------------             |  /--*  const     ref    null $VN.Null\r\nN003 (  5,  4) [000468] -A--G---R---             \\--*  =         ref    $VN.Null\r\nN002 (  3,  2) [000467] D------N----                \\--*  lclVar    ref    V57 tmp48        d:3 $VN.Null\r\n\r\n***** BB10, stmt 22\r\n     ( 14, 10) [000339] ------------             *  stmtExpr  void  (IL   ???...  ???)\r\nN004 (  3,  2) [000990] -------N----             |     /--*  lclVar    ref    V57 tmp48        u:3 (last use) $VN.Null\r\nN006 (  7,  5) [000991] -A------R---             |  /--*  =         ref    $VN.Null\r\nN005 (  3,  2) [000989] D------N----             |  |  \\--*  lclVar    ref    V55 tmp46        d:3 $VN.Null\r\nN007 ( 14, 10) [000992] -A----------             \\--*  comma     void   $VN.Null\r\nN001 (  3,  2) [000987] -------N----                |  /--*  lclVar    ref    V56 tmp47        u:3 (last use) $2aa\r\nN003 (  7,  5) [000988] -A------R---                \\--*  =         ref    $2aa\r\nN002 (  3,  2) [000986] D------N----                   \\--*  lclVar    ref    V54 tmp45        d:3 $2aa\r\n\r\n***** BB10, stmt 23\r\n     ( 14, 10) [000502] ------------             *  stmtExpr  void  (IL   ???...  ???)\r\nN004 (  3,  2) [000997] -------N----             |     /--*  lclVar    ref    V55 tmp46        u:3 (last use) $VN.Null\r\nN006 (  7,  5) [000998] -A------R---             |  /--*  =         ref    $VN.Null\r\nN005 (  3,  2) [000996] D------N----             |  |  \\--*  lclVar    ref    V59 tmp50        d:3 $VN.Null\r\nN007 ( 14, 10) [000999] -A----------             \\--*  comma     void   $VN.Null\r\nN001 (  3,  2) [000994] -------N----                |  /--*  lclVar    ref    V54 tmp45        u:3 (last use) $2aa\r\nN003 (  7,  5) [000995] -A------R---                \\--*  =         ref    $2aa\r\nN002 (  3,  2) [000993] D------N----                   \\--*  lclVar    ref    V58 tmp49        d:3 $2aa\r\n\r\n```\r\n\r\nSimilar redundant assignments/copies occur at 6 different places within the same method.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/comments/257026160","html_url":"https://github.com/dotnet/coreclr/issues/7434#issuecomment-257026160","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/7434","id":257026160,"user":{"login":"JosephTremoulet","id":10655216,"avatar_url":"https://avatars.githubusercontent.com/u/10655216?v=3","gravatar_id":"","url":"https://api.github.com/users/JosephTremoulet","html_url":"https://github.com/JosephTremoulet","followers_url":"https://api.github.com/users/JosephTremoulet/followers","following_url":"https://api.github.com/users/JosephTremoulet/following{/other_user}","gists_url":"https://api.github.com/users/JosephTremoulet/gists{/gist_id}","starred_url":"https://api.github.com/users/JosephTremoulet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JosephTremoulet/subscriptions","organizations_url":"https://api.github.com/users/JosephTremoulet/orgs","repos_url":"https://api.github.com/users/JosephTremoulet/repos","events_url":"https://api.github.com/users/JosephTremoulet/events{/privacy}","received_events_url":"https://api.github.com/users/JosephTremoulet/received_events","type":"User","site_admin":false},"created_at":"2016-10-28T20:55:35Z","updated_at":"2016-10-28T20:55:35Z","body":"As for the assignment chain that begins with `nullptr`, I looked to see why constant prop wasn't kicking in.  It turns out to be due to some of the `GTF_DONT_CSE` annotations that are temporarily in place as part of the 1st-class-struct work; commenting out a few of those (already marked with `TODO-1stClassStructs` comments) enables constant propagation and improves the resulting code sequences, so no new issues are needed to track them (and #7677 may get them)."}}
{"actor":{"display_login":"JosephTremoulet"}}