|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
31 | 31 | import java.util.List;
|
32 | 32 |
|
33 | 33 | import jdk.graal.compiler.core.common.type.Stamp;
|
| 34 | +import jdk.graal.compiler.graph.Node; |
34 | 35 | import jdk.graal.compiler.graph.NodeClass;
|
35 | 36 | import jdk.graal.compiler.nodeinfo.NodeInfo;
|
36 | 37 | import jdk.graal.compiler.nodes.AbstractBeginNode;
|
| 38 | +import jdk.graal.compiler.nodes.FixedGuardNode; |
| 39 | +import jdk.graal.compiler.nodes.GuardNode; |
37 | 40 | import jdk.graal.compiler.nodes.IfNode;
|
38 | 41 | import jdk.graal.compiler.nodes.LogicNode;
|
39 | 42 | import jdk.graal.compiler.nodes.NodeView;
|
@@ -65,6 +68,14 @@ public ValueNode getY() {
|
65 | 68 | return y;
|
66 | 69 | }
|
67 | 70 |
|
| 71 | + @Override |
| 72 | + protected boolean verifyNode() { |
| 73 | + for (Node usage : usages()) { |
| 74 | + assertTrue(usage instanceof GuardNode || usage instanceof FixedGuardNode || usage instanceof IfNode, "exact overflow node must only be used by guards or ifs, found: %s", usage); |
| 75 | + } |
| 76 | + return super.verifyNode(); |
| 77 | + } |
| 78 | + |
68 | 79 | /**
|
69 | 80 | * Make sure the overflow detection nodes have the same order of inputs as the exact arithmetic
|
70 | 81 | * nodes.
|
@@ -119,5 +130,12 @@ public void simplify(SimplifierTool tool) {
|
119 | 130 |
|
120 | 131 | coupledNodes.forEach(n -> n.replaceAndDelete(split));
|
121 | 132 | }
|
| 133 | + if (hasNoUsages()) { |
| 134 | + /* |
| 135 | + * We don't want GVN during canonicalization to find this node and give it usages again, |
| 136 | + * since the canonicalizer would not call this simplify method again. |
| 137 | + */ |
| 138 | + safeDelete(); |
| 139 | + } |
122 | 140 | }
|
123 | 141 | }
|
0 commit comments