# HG changeset patch # User Tom Rodriguez # Date 1439248963 25200 # Node ID b20e743478d3da2d335bfeb1e7edfe394a442e7a # Parent c96f260ac76d90a48d2ab96dffd7934ebf662466 Unguarded floating read should adopt Pi guard if possible diff -r c96f260ac76d -r b20e743478d3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/memory/FloatingReadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/memory/FloatingReadNode.java Mon Aug 10 16:22:28 2015 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/memory/FloatingReadNode.java Mon Aug 10 16:22:43 2015 -0700 @@ -75,9 +75,17 @@ public Node canonical(CanonicalizerTool tool) { if (getAddress() instanceof OffsetAddressNode) { OffsetAddressNode objAddress = (OffsetAddressNode) getAddress(); - if (objAddress.getBase() instanceof PiNode && ((PiNode) objAddress.getBase()).getGuard() == getGuard()) { - OffsetAddressNode newAddress = new OffsetAddressNode(((PiNode) objAddress.getBase()).getOriginalNode(), objAddress.getOffset()); - return new FloatingReadNode(newAddress, getLocationIdentity(), getLastLocationAccess(), stamp(), getGuard(), getBarrierType()); + if (objAddress.getBase() instanceof PiNode) { + PiNode piBase = (PiNode) objAddress.getBase(); + /* + * If the Pi and the read have the same guard or the read is unguarded, use the + * guard of the Pi along with the original value. This encourages a canonical form + * guarded reads. + */ + if (piBase.getGuard() == getGuard() || getGuard() == null) { + OffsetAddressNode newAddress = new OffsetAddressNode(piBase.getOriginalNode(), objAddress.getOffset()); + return new FloatingReadNode(newAddress, getLocationIdentity(), getLastLocationAccess(), stamp(), getGuard() == null ? piBase.getGuard() : getGuard(), getBarrierType()); + } } } return ReadNode.canonicalizeRead(this, getAddress(), getLocationIdentity(), tool);