-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
The ssa opt pass currently abort matching if the rule go through a phis.
For example:
if c {
y = -y
} else {
y *= 2
}
x += yShould be rewriten:
if c {
x -= y
} else {
x += y * 2
}The necessary rules for that optimization already exists, but they can't be applied since a phi node is in the way.
When encountering a phi node opt should start a routine to apply the rule on all branches where that would remove uses of the previous values in that branch (this is because we don't want to generate dupped code that would slower) (and generate a new fallback block that applies the current operation for branches that didn't matched).
This could lead to a jump in codesize since multiple branches might have the same rules applies to them.
A pass that perform CSE but downward in the control flow would regain that lost space.
The extra compilation time cost might not be worth it.