{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/224562021","pull_request_review_id":163961185,"id":224562021,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNDU2MjAyMQ==","diff_hunk":"@@ -1150,6 +1191,180 @@ void SESERegionBuilder::ensureSingleExitFromLoops() {\n   }\n }\n \n+void SingleExitLoopTransformer::unrollLoopBodyOnce() {\n+  // Consider the following example:\n+  //\n+  //   do {\n+  //     i += 1\n+  //     if (...) break;\n+  //     i += 1\n+  //   } while(...)\n+  //   return i\n+  //\n+  // The SIL CFG is shown below:\n+  //\n+  //   preheader:\n+  //     i0 = 0\n+  //     br header(i0)\n+  //\n+  //   header(i1):\n+  //     i2 = i1 + 1\n+  //     cond ??, break, body\n+  //\n+  //   break:\n+  //     br exit(i2)\n+  //\n+  //   body:\n+  //     i3 = i2 + 1\n+  //     cond ??, header(i3), exit(i3)\n+  //\n+  //   exit(i4):\n+  //     return i4\n+  //\n+  // Note that the dataflow between iterations of the loop is captured by\n+  // argument `i1` of the header. If we need to exit from the header of the\n+  // loop, we will need to \"freeze\" the state at the current exit points and\n+  // propagate it to the new header. The canonicalization pass does that by\n+  // adding an argument to the header and passing it from the exit points. See","path":"lib/SILOptimizer/Mandatory/TFCanonicalizeCFG.cpp","position":null,"original_position":179,"commit_id":"472ee0d2884794993892ba4106116bcd9d5a3969","original_commit_id":"9b6e3612e89316c172aa91f0da7076511f4712f6","user":{"login":"bgogul","id":6721579,"node_id":"MDQ6VXNlcjY3MjE1Nzk=","avatar_url":"https://avatars3.githubusercontent.com/u/6721579?v=4","gravatar_id":"","url":"https://api.github.com/users/bgogul","html_url":"https://github.com/bgogul","followers_url":"https://api.github.com/users/bgogul/followers","following_url":"https://api.github.com/users/bgogul/following{/other_user}","gists_url":"https://api.github.com/users/bgogul/gists{/gist_id}","starred_url":"https://api.github.com/users/bgogul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgogul/subscriptions","organizations_url":"https://api.github.com/users/bgogul/orgs","repos_url":"https://api.github.com/users/bgogul/repos","events_url":"https://api.github.com/users/bgogul/events{/privacy}","received_events_url":"https://api.github.com/users/bgogul/received_events","type":"User","site_admin":false},"body":"I meant exit points from the loop. Clarified the comment. ","created_at":"2018-10-11T18:45:46Z","updated_at":"2018-10-11T18:45:50Z","html_url":"https://github.com/apple/swift/pull/19811#discussion_r224562021","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/19811","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/224562021"},"html":{"href":"https://github.com/apple/swift/pull/19811#discussion_r224562021"},"pull_request":{"href":"https://api.github.com/repos/apple/swift/pulls/19811"}},"in_reply_to_id":224289920},"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/19811","id":221624611,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxNjI0NjEx","html_url":"https://github.com/apple/swift/pull/19811","diff_url":"https://github.com/apple/swift/pull/19811.diff","patch_url":"https://github.com/apple/swift/pull/19811.patch","issue_url":"https://api.github.com/repos/apple/swift/issues/19811","number":19811,"state":"open","locked":false,"title":"SESE canonicalization: unroll loop to eliminate undefs.","user":{"login":"bgogul","id":6721579,"node_id":"MDQ6VXNlcjY3MjE1Nzk=","avatar_url":"https://avatars3.githubusercontent.com/u/6721579?v=4","gravatar_id":"","url":"https://api.github.com/users/bgogul","html_url":"https://github.com/bgogul","followers_url":"https://api.github.com/users/bgogul/followers","following_url":"https://api.github.com/users/bgogul/following{/other_user}","gists_url":"https://api.github.com/users/bgogul/gists{/gist_id}","starred_url":"https://api.github.com/users/bgogul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgogul/subscriptions","organizations_url":"https://api.github.com/users/bgogul/orgs","repos_url":"https://api.github.com/users/bgogul/repos","events_url":"https://api.github.com/users/bgogul/events{/privacy}","received_events_url":"https://api.github.com/users/bgogul/received_events","type":"User","site_admin":false},"body":"This patch takes care of the case, where we can eliminate an undef only by unrolling the loop body once. The doWhileLoop example in test/TensorFlow/sese_canonicalization.sil has an example. \r\n\r\nThe implementation is straightforward and simply uses the SILCloner. ","created_at":"2018-10-10T00:20:29Z","updated_at":"2018-10-11T18:45:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9bc31550b9623cbd0e9cb8c1e2aa63134a044c26","assignee":null,"assignees":[],"requested_reviewers":[{"login":"lattner","id":15152540,"node_id":"MDQ6VXNlcjE1MTUyNTQw","avatar_url":"https://avatars0.githubusercontent.com/u/15152540?v=4","gravatar_id":"","url":"https://api.github.com/users/lattner","html_url":"https://github.com/lattner","followers_url":"https://api.github.com/users/lattner/followers","following_url":"https://api.github.com/users/lattner/following{/other_user}","gists_url":"https://api.github.com/users/lattner/gists{/gist_id}","starred_url":"https://api.github.com/users/lattner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lattner/subscriptions","organizations_url":"https://api.github.com/users/lattner/orgs","repos_url":"https://api.github.com/users/lattner/repos","events_url":"https://api.github.com/users/lattner/events{/privacy}","received_events_url":"https://api.github.com/users/lattner/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift/pulls/19811/commits","review_comments_url":"https://api.github.com/repos/apple/swift/pulls/19811/comments","review_comment_url":"https://api.github.com/repos/apple/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift/issues/19811/comments","statuses_url":"https://api.github.com/repos/apple/swift/statuses/472ee0d2884794993892ba4106116bcd9d5a3969","head":{"label":"bgogul:sese_unroll_loop","ref":"sese_unroll_loop","sha":"472ee0d2884794993892ba4106116bcd9d5a3969","user":{"login":"bgogul","id":6721579,"node_id":"MDQ6VXNlcjY3MjE1Nzk=","avatar_url":"https://avatars3.githubusercontent.com/u/6721579?v=4","gravatar_id":"","url":"https://api.github.com/users/bgogul","html_url":"https://github.com/bgogul","followers_url":"https://api.github.com/users/bgogul/followers","following_url":"https://api.github.com/users/bgogul/following{/other_user}","gists_url":"https://api.github.com/users/bgogul/gists{/gist_id}","starred_url":"https://api.github.com/users/bgogul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgogul/subscriptions","organizations_url":"https://api.github.com/users/bgogul/orgs","repos_url":"https://api.github.com/users/bgogul/repos","events_url":"https://api.github.com/users/bgogul/events{/privacy}","received_events_url":"https://api.github.com/users/bgogul/received_events","type":"User","site_admin":false},"repo":{"id":138326487,"node_id":"MDEwOlJlcG9zaXRvcnkxMzgzMjY0ODc=","name":"swift","full_name":"bgogul/swift","private":false,"owner":{"login":"bgogul","id":6721579,"node_id":"MDQ6VXNlcjY3MjE1Nzk=","avatar_url":"https://avatars3.githubusercontent.com/u/6721579?v=4","gravatar_id":"","url":"https://api.github.com/users/bgogul","html_url":"https://github.com/bgogul","followers_url":"https://api.github.com/users/bgogul/followers","following_url":"https://api.github.com/users/bgogul/following{/other_user}","gists_url":"https://api.github.com/users/bgogul/gists{/gist_id}","starred_url":"https://api.github.com/users/bgogul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgogul/subscriptions","organizations_url":"https://api.github.com/users/bgogul/orgs","repos_url":"https://api.github.com/users/bgogul/repos","events_url":"https://api.github.com/users/bgogul/events{/privacy}","received_events_url":"https://api.github.com/users/bgogul/received_events","type":"User","site_admin":false},"html_url":"https://github.com/bgogul/swift","description":"The Swift Programming Language","fork":true,"url":"https://api.github.com/repos/bgogul/swift","forks_url":"https://api.github.com/repos/bgogul/swift/forks","keys_url":"https://api.github.com/repos/bgogul/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bgogul/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bgogul/swift/teams","hooks_url":"https://api.github.com/repos/bgogul/swift/hooks","issue_events_url":"https://api.github.com/repos/bgogul/swift/issues/events{/number}","events_url":"https://api.github.com/repos/bgogul/swift/events","assignees_url":"https://api.github.com/repos/bgogul/swift/assignees{/user}","branches_url":"https://api.github.com/repos/bgogul/swift/branches{/branch}","tags_url":"https://api.github.com/repos/bgogul/swift/tags","blobs_url":"https://api.github.com/repos/bgogul/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bgogul/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bgogul/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/bgogul/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bgogul/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/bgogul/swift/languages","stargazers_url":"https://api.github.com/repos/bgogul/swift/stargazers","contributors_url":"https://api.github.com/repos/bgogul/swift/contributors","subscribers_url":"https://api.github.com/repos/bgogul/swift/subscribers","subscription_url":"https://api.github.com/repos/bgogul/swift/subscription","commits_url":"https://api.github.com/repos/bgogul/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/bgogul/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/bgogul/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/bgogul/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/bgogul/swift/contents/{+path}","compare_url":"https://api.github.com/repos/bgogul/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bgogul/swift/merges","archive_url":"https://api.github.com/repos/bgogul/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bgogul/swift/downloads","issues_url":"https://api.github.com/repos/bgogul/swift/issues{/number}","pulls_url":"https://api.github.com/repos/bgogul/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/bgogul/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/bgogul/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bgogul/swift/labels{/name}","releases_url":"https://api.github.com/repos/bgogul/swift/releases{/id}","deployments_url":"https://api.github.com/repos/bgogul/swift/deployments","created_at":"2018-06-22T16:46:45Z","updated_at":"2018-08-06T20:56:52Z","pushed_at":"2018-10-11T18:37:29Z","git_url":"git://github.com/bgogul/swift.git","ssh_url":"git@github.com:bgogul/swift.git","clone_url":"https://github.com/bgogul/swift.git","svn_url":"https://github.com/bgogul/swift","homepage":"https://swift.org/","size":346738,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apple:tensorflow","ref":"tensorflow","sha":"14c03eab78aec0de6a3fa3e50fb16a58336a8b52","user":{"login":"apple","id":10639145,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjM5MTQ1","avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"repo":{"id":44838949,"node_id":"MDEwOlJlcG9zaXRvcnk0NDgzODk0OQ==","name":"swift","full_name":"apple/swift","private":false,"owner":{"login":"apple","id":10639145,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjM5MTQ1","avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/apple/swift","description":"The Swift Programming Language","fork":false,"url":"https://api.github.com/repos/apple/swift","forks_url":"https://api.github.com/repos/apple/swift/forks","keys_url":"https://api.github.com/repos/apple/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apple/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apple/swift/teams","hooks_url":"https://api.github.com/repos/apple/swift/hooks","issue_events_url":"https://api.github.com/repos/apple/swift/issues/events{/number}","events_url":"https://api.github.com/repos/apple/swift/events","assignees_url":"https://api.github.com/repos/apple/swift/assignees{/user}","branches_url":"https://api.github.com/repos/apple/swift/branches{/branch}","tags_url":"https://api.github.com/repos/apple/swift/tags","blobs_url":"https://api.github.com/repos/apple/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apple/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apple/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/apple/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apple/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/apple/swift/languages","stargazers_url":"https://api.github.com/repos/apple/swift/stargazers","contributors_url":"https://api.github.com/repos/apple/swift/contributors","subscribers_url":"https://api.github.com/repos/apple/swift/subscribers","subscription_url":"https://api.github.com/repos/apple/swift/subscription","commits_url":"https://api.github.com/repos/apple/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/apple/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/apple/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/apple/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/apple/swift/contents/{+path}","compare_url":"https://api.github.com/repos/apple/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apple/swift/merges","archive_url":"https://api.github.com/repos/apple/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apple/swift/downloads","issues_url":"https://api.github.com/repos/apple/swift/issues{/number}","pulls_url":"https://api.github.com/repos/apple/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/apple/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/apple/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apple/swift/labels{/name}","releases_url":"https://api.github.com/repos/apple/swift/releases{/id}","deployments_url":"https://api.github.com/repos/apple/swift/deployments","created_at":"2015-10-23T21:15:07Z","updated_at":"2018-10-11T18:37:59Z","pushed_at":"2018-10-11T18:37:33Z","git_url":"git://github.com/apple/swift.git","ssh_url":"git@github.com:apple/swift.git","clone_url":"https://github.com/apple/swift.git","svn_url":"https://github.com/apple/swift","homepage":"https://swift.org","size":349799,"stargazers_count":45450,"watchers_count":45450,"language":"C++","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7202,"mirror_url":null,"archived":false,"open_issues_count":383,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":7202,"open_issues":383,"watchers":45450,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/19811"},"html":{"href":"https://github.com/apple/swift/pull/19811"},"issue":{"href":"https://api.github.com/repos/apple/swift/issues/19811"},"comments":{"href":"https://api.github.com/repos/apple/swift/issues/19811/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift/pulls/19811/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift/pulls/19811/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift/statuses/472ee0d2884794993892ba4106116bcd9d5a3969"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"bgogul"}}