# HG changeset patch # User Gilles Duboscq # Date 1406899166 -7200 # Node ID f2cd7b3d5aefc539fab9c7f3367dea356cfa924b # Parent 7cdd7ede912d918a305efa133a9b684d6c99e094 unswitching: check full SwitchNode structure diff -r 7cdd7ede912d -r f2cd7b3d5aef graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java Fri Jul 25 13:12:32 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java Fri Aug 01 15:19:26 2014 +0200 @@ -167,7 +167,7 @@ invariantValue = switchNode.value(); controls = new ArrayList<>(); controls.add(switchNode); - } else if (switchNode.value() == invariantValue && firstSwitch.equalKeys(switchNode)) { + } else if (switchNode.value() == invariantValue && firstSwitch.structureEquals(switchNode)) { // Only collect switches which test the same values in the same order controls.add(switchNode); } diff -r 7cdd7ede912d -r f2cd7b3d5aef graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/SwitchNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/SwitchNode.java Fri Jul 25 13:12:32 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/SwitchNode.java Fri Aug 01 15:19:26 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.nodes.extended; +import java.util.*; + import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.type.*; @@ -103,6 +105,10 @@ */ public abstract Constant keyAt(int i); + public boolean structureEquals(SwitchNode switchNode) { + return Arrays.equals(keySuccessors, switchNode.keySuccessors) && equalKeys(switchNode); + } + /** * Returns true if the switch has the same keys in the same order as this switch. */