{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/218981745","pull_request_review_id":157044237,"id":218981745,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxODk4MTc0NQ==","diff_hunk":"@@ -142,7 +143,10 @@ namespace {\n       // Apply the standard SIL loop canonicalization transformations.  This\n       // automatically gives us the following invariants: loops are guaranteed\n       // to have a single preheader, a single backedge block, and exit??\n-      canonicalizeAllLoops(&DI, &LI);\n+      if (canonicalizeAllLoops(&DI, &LI)) {\n+        // Recalculate PDI if canonicalization made any changes.\n+        PDI.recalculate(*F);","path":"lib/SILOptimizer/Mandatory/TFCanonicalizeCFG.cpp","position":15,"original_position":15,"commit_id":"60493b1e3f49857eb9875775ce846acaee936255","original_commit_id":"98e7a06539452c855c8802dce308731f4a95c3e4","user":{"login":"mhong","id":969799,"node_id":"MDQ6VXNlcjk2OTc5OQ==","avatar_url":"https://avatars3.githubusercontent.com/u/969799?v=4","gravatar_id":"","url":"https://api.github.com/users/mhong","html_url":"https://github.com/mhong","followers_url":"https://api.github.com/users/mhong/followers","following_url":"https://api.github.com/users/mhong/following{/other_user}","gists_url":"https://api.github.com/users/mhong/gists{/gist_id}","starred_url":"https://api.github.com/users/mhong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhong/subscriptions","organizations_url":"https://api.github.com/users/mhong/orgs","repos_url":"https://api.github.com/users/mhong/repos","events_url":"https://api.github.com/users/mhong/events{/privacy}","received_events_url":"https://api.github.com/users/mhong/received_events","type":"User","site_admin":false},"body":"i also noticed processAcyclicRegionExcludingEnd() may not need to be public.","created_at":"2018-09-19T22:15:13Z","updated_at":"2018-09-19T22:15:13Z","html_url":"https://github.com/apple/swift/pull/19385#discussion_r218981745","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/19385","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/218981745"},"html":{"href":"https://github.com/apple/swift/pull/19385#discussion_r218981745"},"pull_request":{"href":"https://api.github.com/repos/apple/swift/pulls/19385"}},"in_reply_to_id":218841540},"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/19385","id":216544358,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2NTQ0MzU4","html_url":"https://github.com/apple/swift/pull/19385","diff_url":"https://github.com/apple/swift/pull/19385.diff","patch_url":"https://github.com/apple/swift/pull/19385.patch","issue_url":"https://api.github.com/repos/apple/swift/issues/19385","number":19385,"state":"open","locked":false,"title":"SESE Loops: transform loops to have single exit block in non-cloning case. ","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 could not break the PR further down. Hopefully the algorithm outline presented here helps.\r\n \r\n### Algorithm Outline\r\n(Note that exiting blocks are _inside_ the loop and exit blocks are _outside_ the loop. Therefore, an exit edge is from an exiting block to an exit block.)\r\n\r\nThis PR takes care of transforming the loop such that the common post dominator of all exit blocks is the new exit block for the loop.  This is one of the several transformations needed to eliminate undef from SESE loops. Consider the following snippet:\r\n```\r\nwhile(...) {\r\n   if (...) {\r\n     ... \r\n     break;\r\n   }\r\n}\r\n```\r\nRecall that the blocks within `if` do not belong to the while loop in the SIL IR. The transformation implemented in this PR has the effect of moving the blocks back into the loop. \r\n\r\n_Step 1. Transform Loop._  (See `ensureSingleExitBlock`)\r\n  - Let `nearestCommonPD` be the  nearest common post-dominator block of all the exit blocks.\r\n  - Move all the blocks reachable from exiting blocks to the `nearestCommonPD` inside the loop. (It is not always possible to move all reachable blocks without cloning some of the them.  See notes below.)\r\n  - Let `exitBlocks` be the set of exit blocks for the loop  after the above transformation.\r\n\r\n_Step 2. Connect exiting blocks to a new latch and unify loop arguments._ (See `patchEdges`)\r\n\r\n(Only changes related to exit arguments are shown here.)\r\n  - Let `exitArgs` be the union of the arguments of all `exitBlocks`. \r\n  - for each `exitArg` in `exitArgs`, add an appropriate argument to the new header block. Let `p0, p1, ..pn` be the new arguments corresponding to exit arguments `a0, a1, a2, ..., an`.\r\n  - For a exit edge `br exit_i(x, y) -> exit_i(a2, a3)`, change the source to `br new_latch(p0, p1, x, y, p4, ..., pn)` \r\n\r\n_Notes._\r\nIf a block is **not** dominated by the header of the loop, we cannot move it into the loop in Step 1. For such cases, we will need to clone the block before moving it into the loop. I will send out a separate PR for that purpose. ","created_at":"2018-09-19T07:49:02Z","updated_at":"2018-09-19T22:15:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cad651155ac5ca0c7dd65e0dbe2e4903a2444e93","assignee":null,"assignees":[],"requested_reviewers":[{"login":"rxwei","id":856507,"node_id":"MDQ6VXNlcjg1NjUwNw==","avatar_url":"https://avatars0.githubusercontent.com/u/856507?v=4","gravatar_id":"","url":"https://api.github.com/users/rxwei","html_url":"https://github.com/rxwei","followers_url":"https://api.github.com/users/rxwei/followers","following_url":"https://api.github.com/users/rxwei/following{/other_user}","gists_url":"https://api.github.com/users/rxwei/gists{/gist_id}","starred_url":"https://api.github.com/users/rxwei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rxwei/subscriptions","organizations_url":"https://api.github.com/users/rxwei/orgs","repos_url":"https://api.github.com/users/rxwei/repos","events_url":"https://api.github.com/users/rxwei/events{/privacy}","received_events_url":"https://api.github.com/users/rxwei/received_events","type":"User","site_admin":false},{"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/19385/commits","review_comments_url":"https://api.github.com/repos/apple/swift/pulls/19385/comments","review_comment_url":"https://api.github.com/repos/apple/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift/issues/19385/comments","statuses_url":"https://api.github.com/repos/apple/swift/statuses/60493b1e3f49857eb9875775ce846acaee936255","head":{"label":"bgogul:reduce_exit_blocks","ref":"reduce_exit_blocks","sha":"60493b1e3f49857eb9875775ce846acaee936255","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-09-19T20:58:50Z","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":326649,"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":"28a35d480e81bb68e7f58974c036e63f8bbcb07f","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-09-19T21:41:42Z","pushed_at":"2018-09-19T22:08:38Z","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":339608,"stargazers_count":45246,"watchers_count":45246,"language":"C++","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7146,"mirror_url":null,"archived":false,"open_issues_count":375,"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":7146,"open_issues":375,"watchers":45246,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/19385"},"html":{"href":"https://github.com/apple/swift/pull/19385"},"issue":{"href":"https://api.github.com/repos/apple/swift/issues/19385"},"comments":{"href":"https://api.github.com/repos/apple/swift/issues/19385/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift/pulls/19385/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift/pulls/19385/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift/statuses/60493b1e3f49857eb9875775ce846acaee936255"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"mhong"}}