-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8325746: Refactor Loop Unswitching code #17842
Closed
+464
−183
Closed
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4fd6d19
8325746: Refactor Loop Unswitching code
chhagedorn f73c5fb
Apply Emanuel's suggestions
chhagedorn 17c27a5
Apply suggestions from code review
chhagedorn 2e0d2a3
Update src/hotspot/share/opto/loopUnswitch.cpp
chhagedorn 40dbdd8
Suggestions by Emanuel
chhagedorn 66532d2
Change block -> path
chhagedorn 574eb60
fix empty path, strip mined loop head
chhagedorn cbcf3dc
Apply suggestions from code review
chhagedorn 9b1d3f1
Vladimir's review
chhagedorn f685395
Update src/hotspot/share/opto/loopUnswitch.cpp
chhagedorn 5a314ff
Fix If creation and add assert with test
chhagedorn 96798d1
Review Emanuel
chhagedorn cb0ec0d
Add additional run
chhagedorn 73faa39
Change to @run main
chhagedorn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,11 +36,11 @@ | |
// Loop Unswitching is a loop optimization to move an invariant, non-loop-exiting test in the loop body before the loop. | ||
// Such a test is either always true or always false in all loop iterations and could therefore only be executed once. | ||
// To achieve that, we duplicate the loop and change the original and cloned loop as follows: | ||
// - Original loop -> true-path-loop: The true-path-block of the invariant, non-loop-exiting test in the original loop | ||
// is kept while the false-path-block is killed. We call this unswitched loop version | ||
// - Original loop -> true-path-loop: The true-path-path of the invariant, non-loop-exiting test in the original loop | ||
// is kept while the false-path-path is killed. We call this unswitched loop version | ||
// the true-path-loop. | ||
// - Cloned loop -> False-path-loop: The false-path-block of the invariant, non-loop-exiting test in the cloned loop | ||
// is kept while the true-path-block is killed. We call this unswitched loop version | ||
// - Cloned loop -> False-path-loop: The false-path-path of the invariant, non-loop-exiting test in the cloned loop | ||
// is kept while the true-path-path is killed. We call this unswitched loop version | ||
// the false-path loop. | ||
// | ||
// The invariant, non-loop-exiting test can now be moved before both loops (to only execute it once) and turned into a | ||
|
@@ -60,12 +60,12 @@ | |
// Original Loop true? false? | ||
// stmt1 / \ | ||
// if (invariant-test) UNSWITCHED [Cloned Parse Predicates] [Cloned Parse Predicates] | ||
// if-block =========> [Cloned Template [Cloned Template | ||
// if-path =========> [Cloned Template [Cloned Template | ||
// else Assertion Predicates] Assertion Predicates] | ||
// // could be empty | | | ||
// [else-block] True-Path-Loop False-Path-Loop | ||
// [else-path] True-Path-Loop False-Path-Loop | ||
// stmt2 cloned stmt1 cloned stmt1 | ||
// Endloop cloned if-block [cloned else-block] | ||
// Endloop cloned if-path [cloned else-path] | ||
// cloned stmt2 cloned stmt2 | ||
// Endloop Endloop | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you put resulting unstitched graph on separate following lines? Comment line are too long. |
||
|
||
|
@@ -245,7 +245,7 @@ class OriginalLoop : public StackObj { | |
#endif // ASSERT | ||
|
||
// Remove the unswitch candidate If nodes in both unswitched loop versions which are now dominated by the loop selector | ||
// If node. Keep the true-path-block in the true-path-loop and the false-path-block in the false-path-loop by setting | ||
// If node. Keep the true-path-path in the true-path-loop and the false-path-path in the false-path-loop by setting | ||
// the bool input accordingly. The unswitch candidate If nodes are folded in the next IGVN round. | ||
void remove_unswitch_candidate_from_loops(const UnswitchedLoopSelector& unswitched_loop_selector) { | ||
IfNode* unswitching_candidate = unswitched_loop_selector.unswitch_candidate(); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be the other way around: the if-path is empty and the else-path has code? Or are you just trying to suggest that there could be an empty path, and that this would really simplify one of the cloned loops now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it would be a simplification. But as suggested in the other comment. It might create more confusion than actually helping.