This phase recognizes
phis that are repeatedly converted back and forth with
lossless conversions. The main use case is i64 phis that actually contain i32/f32/f64 values and
that use
NarrowNode,
ZeroExtendNode,
SignExtendNode,
AnyExtendNode and
ReinterpretNode for conversion. In loop nests and complex
control flow, multiple phis may need to be transformed as a group.
In order to be considered, phis can only have constants, other phis in the group, or an
appropriate conversion as an input (see
PhiTransformPhase.isValidInput(ValueNode, UnaryNode, boolean, EconomicSet). Also, usages can only be other
phis in the group, appropriate conversions, or
VirtualObjectStates (see
PhiTransformPhase.collectNodes(ValueNode, EconomicSet, UnaryNode, ResolvedJavaType)).
If there is any virtual object state usage in the group, the transformation cannot be a
SignExtendNode, because only zero extend can be expressed in virtual state.
As this phase is intended to run on graphs that still contain proxies, it takes the proxies
between phis into account.
long v = 0L;
long v2 = Float.floatToRawIntBits(0f) & 0xFFFFFFFFL; // v2 = zeroextend(reinterpret(0.0))
for (...) {
v = (((int) v) + 123) & 0xFFFFFFFFL; // v = zeroextend(narrow(v) + 123)
v2 = Float.floatToRawIntBits(Float.intBitsToFloat((int) v2) + 1f) & 0xFFFFFFFFL; // v2 = zeroextend(reinterpret(reinterpret(narrow(v2)) + 1f))
}
float s = Float.intBitsToFloat((int) v2); // s = reinterpret(narrow(v2))
return (int) v; // narrow(v)
will be transformed to:
int v = 0;
float v2 = 0f;
for (...) {
v = v + 123;
v2 = v2 + 1f;
}
float s = v2;
return v;