forked from p4lang/p4c
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Predication pass optimization for nested if statements (p4lang#2083) (p…
…4lang#2231) * Predication pass optimization for nested ifs * Implementation without vector with predicates for each if * ExpressionReplacer for IR::Mux * Output test changed * Expression Replacer preorder Mux implemented * Implemented ExpressionChecker * Tests output changed * Predication pass optimization for nested if statements (p4lang#2083)Refactored Predication pass, because of the issue p4lang#2083 in which LocalCopyProp passcreates quadratically more complex code for chained if-else statements.Predication pass is optimized by looking for same assignment statements in both thenand else branches and then converting them to the ternary expression if possible.It will not be possible to convert more than one assignment if they have dependenciesbetween each other.For the basic example with one if-else statement like this:if(e) x = 5;else x = 10;Code will be transformed to this:x = e ? 5 : 10;New implementation of Predication pass relies on keeping track of the transformedlive assignments which will be inserted into the right place in IR, after visitingboth if and else statements of the corresponding block.ExpressionReplacer transforms expression on the right side of the assignment intoternary operator(IR::Mux) or nested ternary operators.ReplaceChecker inspects if the assignment statement could be emplaced into thenested ternary operator. * Removed ReplaceChecker, refactored using Context Visitor ReplaceChecker is unnecessary because it is covered by dependecy prints. ExpressionReplacer now uses VisitorContext class. Removed redundant checks. * ordered Names erasing changed * Removed unused includes Co-authored-by: Your Name <you@example.com> Co-authored-by: matijalukic <matijalukictutorijal@gmail.com>
- Loading branch information
1 parent
c120950
commit 0190f95
Showing
35 changed files
with
2,279 additions
and
136 deletions.
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
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
Oops, something went wrong.