annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerEqualsNode.java @ 19403:61d3cb8e1280

Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 16 Feb 2015 17:47:43 +0100
parents 7e2c87dae93e
children 8fc336a04d77 b017118b412b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
1 /*
18839
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18188
diff changeset
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
4 *
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
8 *
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
13 * accompanied this code).
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
14 *
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
18 *
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
21 * questions.
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
22 */
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
23 package com.oracle.graal.nodes.calc;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
24
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5504
diff changeset
25 import com.oracle.graal.api.meta.*;
15975
0ad889977080 CompareNode.canonicalizeSymmetricConstant can lead to float<->int changes so the right type of node needs to be created depending on the inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15961
diff changeset
26 import com.oracle.graal.compiler.common.*;
15200
97eed257999b Move Condition to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 14711
diff changeset
27 import com.oracle.graal.compiler.common.calc.*;
15261
882f4cb7cfcf Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15200
diff changeset
28 import com.oracle.graal.compiler.common.type.*;
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
29 import com.oracle.graal.graph.*;
11881
da9db8331658 moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11880
diff changeset
30 import com.oracle.graal.graph.spi.*;
16841
cbd42807a31f moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents: 16822
diff changeset
31 import com.oracle.graal.nodeinfo.*;
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
32 import com.oracle.graal.nodes.*;
14711
ba4b79da6351 canonicalize certain shift-compare expressions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14633
diff changeset
33 import com.oracle.graal.nodes.util.*;
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
34
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
35 @NodeInfo(shortName = "==")
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19115
diff changeset
36 public final class IntegerEqualsNode extends CompareNode {
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19396
diff changeset
37 public static final NodeClass<IntegerEqualsNode> TYPE = NodeClass.get(IntegerEqualsNode.class);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
38
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
39 public IntegerEqualsNode(ValueNode x, ValueNode y) {
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
40 super(TYPE, Condition.EQ, false, x, y);
14633
da2431cc1506 Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents: 12695
diff changeset
41 assert !x.getKind().isNumericFloat() && x.getKind() != Kind.Object;
da2431cc1506 Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents: 12695
diff changeset
42 assert !y.getKind().isNumericFloat() && y.getKind() != Kind.Object;
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
43 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
44
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19115
diff changeset
45 public static LogicNode create(ValueNode x, ValueNode y, ConstantReflectionProvider constantReflection) {
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19115
diff changeset
46 LogicNode result = CompareNode.tryConstantFold(Condition.EQ, x, y, constantReflection, false);
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19115
diff changeset
47 if (result != null) {
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19115
diff changeset
48 return result;
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19115
diff changeset
49 } else {
19373
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
50 if (x instanceof ConditionalNode) {
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
51 ConditionalNode conditionalNode = (ConditionalNode) x;
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
52 if (conditionalNode.trueValue() == y) {
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
53 return conditionalNode.condition();
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
54 }
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
55 if (conditionalNode.falseValue() == y) {
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
56 return LogicNegationNode.create(conditionalNode.condition());
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
57 }
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
58 } else if (y instanceof ConditionalNode) {
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
59 ConditionalNode conditionalNode = (ConditionalNode) y;
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
60 if (conditionalNode.trueValue() == x) {
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
61 return conditionalNode.condition();
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
62 }
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
63 if (conditionalNode.falseValue() == x) {
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
64 return LogicNegationNode.create(conditionalNode.condition());
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
65 }
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
66 }
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19147
diff changeset
67
19147
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19115
diff changeset
68 return new IntegerEqualsNode(x, y);
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19115
diff changeset
69 }
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19115
diff changeset
70 }
609480dfa0d8 Create ExplodeLoop plugin prototype. Special sort for blocks from bci block map builder for explode loop methods. Graph builder plugin for customizing static field accesses. New Truffle option TruffleExcludeAssertions default true that excludes assertion code from being partial evaluated in the new partial evaluator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19115
diff changeset
71
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
72 @Override
18188
8652481a1110 Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
73 protected ValueNode optimizeNormalizeCmp(Constant constant, NormalizeCompareNode normalizeNode, boolean mirrored) {
8652481a1110 Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
74 PrimitiveConstant primitive = (PrimitiveConstant) constant;
8652481a1110 Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
75 if (primitive.getKind() == Kind.Int && primitive.asInt() == 0) {
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15975
diff changeset
76 ValueNode a = mirrored ? normalizeNode.getY() : normalizeNode.getX();
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15975
diff changeset
77 ValueNode b = mirrored ? normalizeNode.getX() : normalizeNode.getY();
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
78
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15975
diff changeset
79 if (normalizeNode.getX().getKind() == Kind.Double || normalizeNode.getX().getKind() == Kind.Float) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
80 return new FloatEqualsNode(a, b);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
81 } else {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
82 return new IntegerEqualsNode(a, b);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
83 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
84 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
85 return this;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
86 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
87
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
88 @Override
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
89 protected CompareNode duplicateModified(ValueNode newX, ValueNode newY) {
15975
0ad889977080 CompareNode.canonicalizeSymmetricConstant can lead to float<->int changes so the right type of node needs to be created depending on the inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15961
diff changeset
90 if (newX.stamp() instanceof FloatStamp && newY.stamp() instanceof FloatStamp) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
91 return new FloatEqualsNode(newX, newY);
15975
0ad889977080 CompareNode.canonicalizeSymmetricConstant can lead to float<->int changes so the right type of node needs to be created depending on the inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15961
diff changeset
92 } else if (newX.stamp() instanceof IntegerStamp && newY.stamp() instanceof IntegerStamp) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
93 return new IntegerEqualsNode(newX, newY);
15975
0ad889977080 CompareNode.canonicalizeSymmetricConstant can lead to float<->int changes so the right type of node needs to be created depending on the inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15961
diff changeset
94 }
0ad889977080 CompareNode.canonicalizeSymmetricConstant can lead to float<->int changes so the right type of node needs to be created depending on the inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15961
diff changeset
95 throw GraalInternalError.shouldNotReachHere();
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
96 }
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
97
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
98 @Override
16212
51c7c676d41a implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16207
diff changeset
99 public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
15349
7766f486f5d6 evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15261
diff changeset
100 if (GraphUtil.unproxify(forX) == GraphUtil.unproxify(forY)) {
16212
51c7c676d41a implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16207
diff changeset
101 return LogicConstantNode.tautology();
15349
7766f486f5d6 evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15261
diff changeset
102 } else if (forX.stamp().alwaysDistinct(forY.stamp())) {
16212
51c7c676d41a implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16207
diff changeset
103 return LogicConstantNode.contradiction();
15349
7766f486f5d6 evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15261
diff changeset
104 }
16212
51c7c676d41a implement Canonicalizable.Binary in the BinaryOpLogicNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16207
diff changeset
105 return super.canonical(tool, forX, forY);
15349
7766f486f5d6 evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15261
diff changeset
106 }
7766f486f5d6 evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15261
diff changeset
107
7766f486f5d6 evaluate for BinaryOpLogicNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15261
diff changeset
108 @Override
18188
8652481a1110 Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
109 protected ValueNode canonicalizeSymmetricConstant(CanonicalizerTool tool, Constant constant, ValueNode nonConstant, boolean mirrored) {
8652481a1110 Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
110 if (constant instanceof PrimitiveConstant && ((PrimitiveConstant) constant).asLong() == 0) {
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
111 if (nonConstant instanceof AndNode) {
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
112 AndNode andNode = (AndNode) nonConstant;
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
113 return new IntegerTestNode(andNode.getX(), andNode.getY());
18839
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18188
diff changeset
114 } else if (nonConstant instanceof ShiftNode && nonConstant.stamp() instanceof IntegerStamp) {
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
115 if (nonConstant instanceof LeftShiftNode) {
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
116 LeftShiftNode shift = (LeftShiftNode) nonConstant;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15975
diff changeset
117 if (shift.getY().isConstant()) {
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
118 int mask = shift.getShiftAmountMask();
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
119 int amount = shift.getY().asJavaConstant().asInt() & mask;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15975
diff changeset
120 if (shift.getX().getKind() == Kind.Int) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
121 return new IntegerTestNode(shift.getX(), ConstantNode.forInt(-1 >>> amount));
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
122 } else {
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15975
diff changeset
123 assert shift.getX().getKind() == Kind.Long;
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
124 return new IntegerTestNode(shift.getX(), ConstantNode.forLong(-1L >>> amount));
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
125 }
14711
ba4b79da6351 canonicalize certain shift-compare expressions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14633
diff changeset
126 }
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
127 } else if (nonConstant instanceof RightShiftNode) {
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
128 RightShiftNode shift = (RightShiftNode) nonConstant;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15975
diff changeset
129 if (shift.getY().isConstant() && ((IntegerStamp) shift.getX().stamp()).isPositive()) {
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
130 int mask = shift.getShiftAmountMask();
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
131 int amount = shift.getY().asJavaConstant().asInt() & mask;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15975
diff changeset
132 if (shift.getX().getKind() == Kind.Int) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
133 return new IntegerTestNode(shift.getX(), ConstantNode.forInt(-1 << amount));
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
134 } else {
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15975
diff changeset
135 assert shift.getX().getKind() == Kind.Long;
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
136 return new IntegerTestNode(shift.getX(), ConstantNode.forLong(-1L << amount));
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
137 }
14711
ba4b79da6351 canonicalize certain shift-compare expressions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14633
diff changeset
138 }
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
139 } else if (nonConstant instanceof UnsignedRightShiftNode) {
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
140 UnsignedRightShiftNode shift = (UnsignedRightShiftNode) nonConstant;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15975
diff changeset
141 if (shift.getY().isConstant()) {
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
142 int mask = shift.getShiftAmountMask();
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
143 int amount = shift.getY().asJavaConstant().asInt() & mask;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15975
diff changeset
144 if (shift.getX().getKind() == Kind.Int) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
145 return new IntegerTestNode(shift.getX(), ConstantNode.forInt(-1 << amount));
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
146 } else {
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15975
diff changeset
147 assert shift.getX().getKind() == Kind.Long;
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18839
diff changeset
148 return new IntegerTestNode(shift.getX(), ConstantNode.forLong(-1L << amount));
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
149 }
14711
ba4b79da6351 canonicalize certain shift-compare expressions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14633
diff changeset
150 }
ba4b79da6351 canonicalize certain shift-compare expressions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14633
diff changeset
151 }
ba4b79da6351 canonicalize certain shift-compare expressions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14633
diff changeset
152 }
ba4b79da6351 canonicalize certain shift-compare expressions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14633
diff changeset
153 }
15961
d5b824a41530 CompareNode refactorings
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15349
diff changeset
154 return super.canonicalizeSymmetricConstant(tool, constant, nonConstant, mirrored);
14711
ba4b79da6351 canonicalize certain shift-compare expressions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14633
diff changeset
155 }
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
156 }