-
Enhancement
-
Resolution: Unresolved
-
P3
-
7, 9, 10
-
Fix Understood
-
generic
-
generic
IfNode::Ideal is responsible for several important optimizations which elimnate redundant tests. There are some improvements we should implement.
1. The current code predates the def-use edges so it sometimes looks for opportunities that don't exist. For instance, the shared bool optimization can only exist if there are multiple users of the bool. This significantly reduces the amount of useless work we do.
2. Currently we limit the search depth in many cases, presumably to reduce the amount of useless work. Given the fix for 1, we can increase the search distance without increasing the amount of work, which finds a few more cases than we used to.
3. Shared CmpNodes also provide opportunity for elimination of ifs, i.e. n > 1 proves that n < 1 is false.
4. up_one_dom should be improved to handle If diamonds with work on only one side.
5. RegionNode::Ideal has a optimization that collapses redundant ifs with a control flow between them, i.e.
if (test) {
WT1
} else {
WF1
}
if (test) {
WT2
} else {
WF2
}
can become:
if (test) {
WT1
WT2
} else {
WF1
WF2
}
as long the Region in between doesn't have phis. IfNode::Ideal is missing something equivalent so sometimes we miss the transformation depending on how the worklist is managed.
6. In some cases pairs of Ifs can be converted into a single unsigned compare which may allow them to eliminate built in range checks.
1. The current code predates the def-use edges so it sometimes looks for opportunities that don't exist. For instance, the shared bool optimization can only exist if there are multiple users of the bool. This significantly reduces the amount of useless work we do.
2. Currently we limit the search depth in many cases, presumably to reduce the amount of useless work. Given the fix for 1, we can increase the search distance without increasing the amount of work, which finds a few more cases than we used to.
3. Shared CmpNodes also provide opportunity for elimination of ifs, i.e. n > 1 proves that n < 1 is false.
4. up_one_dom should be improved to handle If diamonds with work on only one side.
5. RegionNode::Ideal has a optimization that collapses redundant ifs with a control flow between them, i.e.
if (test) {
WT1
} else {
WF1
}
if (test) {
WT2
} else {
WF2
}
can become:
if (test) {
WT1
WT2
} else {
WF1
WF2
}
as long the Region in between doesn't have phis. IfNode::Ideal is missing something equivalent so sometimes we miss the transformation depending on how the worklist is managed.
6. In some cases pairs of Ifs can be converted into a single unsigned compare which may allow them to eliminate built in range checks.