annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitOrNode.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9443
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
1 /*
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
9443
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
4 *
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
8 *
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
13 * accompanied this code).
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
14 *
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
18 *
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
21 * questions.
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
22 */
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
23 package com.oracle.graal.nodes;
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
24
11580
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
25 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
26 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
27 import com.oracle.graal.nodeinfo.*;
9443
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
28
16822
5d468add216f added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents: 16250
diff changeset
29 @NodeInfo
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19373
diff changeset
30 public final class ShortCircuitOrNode extends LogicNode implements IterableNodeType, Canonicalizable.Binary<LogicNode> {
11580
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
31
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
32 public static final NodeClass<ShortCircuitOrNode> TYPE = NodeClass.get(ShortCircuitOrNode.class);
16897
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
33 @Input(InputType.Condition) LogicNode x;
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
34 @Input(InputType.Condition) LogicNode y;
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
35 protected boolean xNegated;
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
36 protected boolean yNegated;
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
37 protected double shortCircuitProbability;
9443
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
38
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
39 public ShortCircuitOrNode(LogicNode x, boolean xNegated, LogicNode y, boolean yNegated, double shortCircuitProbability) {
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);
11580
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
41 this.x = x;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
42 this.xNegated = xNegated;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
43 this.y = y;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
44 this.yNegated = yNegated;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
45 this.shortCircuitProbability = shortCircuitProbability;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
46 }
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
47
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
48 public LogicNode getX() {
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
49 return x;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
50 }
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
51
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
52 public LogicNode getY() {
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
53 return y;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
54 }
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
55
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
56 public boolean isXNegated() {
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
57 return xNegated;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
58 }
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
59
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
60 public boolean isYNegated() {
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
61 return yNegated;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
62 }
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
63
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
64 /**
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
65 * Gets the probability that the {@link #getY() y} part of this binary node is <b>not</b>
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
66 * evaluated. This is the probability that this operator will short-circuit its execution.
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
67 */
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
68 public double getShortCircuitProbability() {
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
69 return shortCircuitProbability;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
70 }
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
71
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
72 protected ShortCircuitOrNode canonicalizeNegation(LogicNode forX, LogicNode forY) {
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
73 LogicNode xCond = forX;
11580
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
74 boolean xNeg = xNegated;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
75 while (xCond instanceof LogicNegationNode) {
16220
4182366b8eed rename getInput() to getValue() in LogicNegationNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
76 xCond = ((LogicNegationNode) xCond).getValue();
11580
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
77 xNeg = !xNeg;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
78 }
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
79
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
80 LogicNode yCond = forY;
11580
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
81 boolean yNeg = yNegated;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
82 while (yCond instanceof LogicNegationNode) {
16220
4182366b8eed rename getInput() to getValue() in LogicNegationNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
83 yCond = ((LogicNegationNode) yCond).getValue();
11580
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
84 yNeg = !yNeg;
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
85 }
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
86
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
87 if (xCond != forX || yCond != forY) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
88 return new ShortCircuitOrNode(xCond, xNeg, yCond, yNeg, shortCircuitProbability);
11580
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
89 } else {
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
90 return this;
11580
5ce62ee0fed7 Remove ShortCircuitAndNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11409
diff changeset
91 }
9443
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
92 }
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
93
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
94 public LogicNode canonical(CanonicalizerTool tool, LogicNode forX, LogicNode forY) {
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
95 ShortCircuitOrNode ret = canonicalizeNegation(forX, forY);
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
96 if (ret != this) {
11409
1f302b6e16b0 Introduce LogicNegationNode and remove Negatable interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 10789
diff changeset
97 return ret;
1f302b6e16b0 Introduce LogicNegationNode and remove Negatable interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 10789
diff changeset
98 }
1f302b6e16b0 Introduce LogicNegationNode and remove Negatable interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 10789
diff changeset
99
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
100 if (forX == forY) {
10713
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
101 // @formatter:off
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
102 // a || a = a
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
103 // a || !a = true
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
104 // !a || a = true
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
105 // !a || !a = !a
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
106 // @formatter:on
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
107 if (isXNegated()) {
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
108 if (isYNegated()) {
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
109 // !a || !a = !a
19373
03adf6499fee Better graph building time canonicalizations for logical negation and conditional node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
110 return LogicNegationNode.create(forX);
10713
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
111 } else {
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
112 // !a || a = true
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
113 return LogicConstantNode.tautology();
10713
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
114 }
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
115 } else {
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
116 if (isYNegated()) {
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
117 // a || !a = true
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
118 return LogicConstantNode.tautology();
10713
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
119 } else {
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
120 // a || a = a
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
121 return forX;
10713
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
122 }
057154505878 fixed canonicalization bug (detected by Gilles) in binary logic nodes
Doug Simon <doug.simon@oracle.com>
parents: 9443
diff changeset
123 }
9443
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
124 }
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
125 if (forX instanceof LogicConstantNode) {
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
126 if (((LogicConstantNode) forX).getValue() ^ isXNegated()) {
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
127 return LogicConstantNode.tautology();
9443
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
128 } else {
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
129 if (isYNegated()) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
130 return new LogicNegationNode(forY);
11409
1f302b6e16b0 Introduce LogicNegationNode and remove Negatable interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 10789
diff changeset
131 } else {
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
132 return forY;
9443
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
133 }
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
134 }
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
135 }
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
136 if (forY instanceof LogicConstantNode) {
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
137 if (((LogicConstantNode) forY).getValue() ^ isYNegated()) {
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
138 return LogicConstantNode.tautology();
9443
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
139 } else {
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
140 if (isXNegated()) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
141 return new LogicNegationNode(forX);
11409
1f302b6e16b0 Introduce LogicNegationNode and remove Negatable interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 10789
diff changeset
142 } else {
16224
68f16c1057d4 let LogicNegationNode and ShortCircuitNode implement Canonicalizable.Unary/Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16220
diff changeset
143 return forX;
9443
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
144 }
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
145 }
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
146 }
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
147 return this;
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
148 }
490d283dbe90 Add Logic conjunction and disjunction and expand them before lir generation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
149 }