src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/FloatEqualsNode.java
changeset 48861 47f19ff9903c
parent 48190 25cfedf27edc
child 50858 2d3e99a72541
equal deleted inserted replaced
48860:5bce1b7e7800 48861:47f19ff9903c
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 package org.graalvm.compiler.nodes.calc;
    23 package org.graalvm.compiler.nodes.calc;
    24 
    24 
    25 import jdk.vm.ci.meta.ConstantReflectionProvider;
    25 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_2;
    26 import jdk.vm.ci.meta.MetaAccessProvider;
    26 
    27 import jdk.vm.ci.meta.TriState;
    27 import org.graalvm.compiler.core.common.calc.CanonicalCondition;
    28 import org.graalvm.compiler.core.common.calc.Condition;
       
    29 import org.graalvm.compiler.core.common.type.FloatStamp;
    28 import org.graalvm.compiler.core.common.type.FloatStamp;
    30 import org.graalvm.compiler.core.common.type.IntegerStamp;
    29 import org.graalvm.compiler.core.common.type.IntegerStamp;
    31 import org.graalvm.compiler.core.common.type.Stamp;
    30 import org.graalvm.compiler.core.common.type.Stamp;
    32 import org.graalvm.compiler.debug.GraalError;
    31 import org.graalvm.compiler.debug.GraalError;
    33 import org.graalvm.compiler.graph.Node;
    32 import org.graalvm.compiler.graph.Node;
    40 import org.graalvm.compiler.nodes.NodeView;
    39 import org.graalvm.compiler.nodes.NodeView;
    41 import org.graalvm.compiler.nodes.ValueNode;
    40 import org.graalvm.compiler.nodes.ValueNode;
    42 import org.graalvm.compiler.nodes.util.GraphUtil;
    41 import org.graalvm.compiler.nodes.util.GraphUtil;
    43 import org.graalvm.compiler.options.OptionValues;
    42 import org.graalvm.compiler.options.OptionValues;
    44 
    43 
    45 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_2;
    44 import jdk.vm.ci.meta.ConstantReflectionProvider;
       
    45 import jdk.vm.ci.meta.MetaAccessProvider;
       
    46 import jdk.vm.ci.meta.TriState;
    46 
    47 
    47 @NodeInfo(shortName = "==", cycles = CYCLES_2)
    48 @NodeInfo(shortName = "==", cycles = CYCLES_2)
    48 public final class FloatEqualsNode extends CompareNode implements BinaryCommutative<ValueNode> {
    49 public final class FloatEqualsNode extends CompareNode implements BinaryCommutative<ValueNode> {
    49     public static final NodeClass<FloatEqualsNode> TYPE = NodeClass.create(FloatEqualsNode.class);
    50     public static final NodeClass<FloatEqualsNode> TYPE = NodeClass.create(FloatEqualsNode.class);
    50     private static final FloatEqualsOp OP = new FloatEqualsOp();
    51     private static final FloatEqualsOp OP = new FloatEqualsOp();
    51 
    52 
    52     public FloatEqualsNode(ValueNode x, ValueNode y) {
    53     public FloatEqualsNode(ValueNode x, ValueNode y) {
    53         super(TYPE, Condition.EQ, false, x, y);
    54         super(TYPE, CanonicalCondition.EQ, false, x, y);
    54         assert x.stamp(NodeView.DEFAULT) instanceof FloatStamp && y.stamp(NodeView.DEFAULT) instanceof FloatStamp : x.stamp(NodeView.DEFAULT) + " " + y.stamp(NodeView.DEFAULT);
    55         assert x.stamp(NodeView.DEFAULT) instanceof FloatStamp && y.stamp(NodeView.DEFAULT) instanceof FloatStamp : x.stamp(NodeView.DEFAULT) + " " + y.stamp(NodeView.DEFAULT);
    55         assert x.stamp(NodeView.DEFAULT).isCompatible(y.stamp(NodeView.DEFAULT));
    56         assert x.stamp(NodeView.DEFAULT).isCompatible(y.stamp(NodeView.DEFAULT));
    56     }
    57     }
    57 
    58 
    58     public static LogicNode create(ValueNode x, ValueNode y, NodeView view) {
    59     public static LogicNode create(ValueNode x, ValueNode y, NodeView view) {
    59         LogicNode result = CompareNode.tryConstantFoldPrimitive(Condition.EQ, x, y, false, view);
    60         LogicNode result = CompareNode.tryConstantFoldPrimitive(CanonicalCondition.EQ, x, y, false, view);
    60         if (result != null) {
    61         if (result != null) {
    61             return result;
    62             return result;
    62         } else {
    63         } else {
    63             return new FloatEqualsNode(x, y).maybeCommuteInputs();
    64             return new FloatEqualsNode(x, y).maybeCommuteInputs();
    64         }
    65         }
    65     }
    66     }
    66 
    67 
    67     public static LogicNode create(ConstantReflectionProvider constantReflection, MetaAccessProvider metaAccess, OptionValues options, Integer smallestCompareWidth,
    68     public static LogicNode create(ConstantReflectionProvider constantReflection, MetaAccessProvider metaAccess, OptionValues options, Integer smallestCompareWidth,
    68                     ValueNode x, ValueNode y, NodeView view) {
    69                     ValueNode x, ValueNode y, NodeView view) {
    69         LogicNode value = OP.canonical(constantReflection, metaAccess, options, smallestCompareWidth, Condition.EQ, false, x, y, view);
    70         LogicNode value = OP.canonical(constantReflection, metaAccess, options, smallestCompareWidth, CanonicalCondition.EQ, false, x, y, view);
    70         if (value != null) {
    71         if (value != null) {
    71             return value;
    72             return value;
    72         }
    73         }
    73         return create(x, y, view);
    74         return create(x, y, view);
    74     }
    75     }
    87     }
    88     }
    88 
    89 
    89     @Override
    90     @Override
    90     public Node canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
    91     public Node canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
    91         NodeView view = NodeView.from(tool);
    92         NodeView view = NodeView.from(tool);
    92         ValueNode value = OP.canonical(tool.getConstantReflection(), tool.getMetaAccess(), tool.getOptions(), tool.smallestCompareWidth(), Condition.EQ, unorderedIsTrue, forX, forY, view);
    93         ValueNode value = OP.canonical(tool.getConstantReflection(), tool.getMetaAccess(), tool.getOptions(), tool.smallestCompareWidth(), CanonicalCondition.EQ, unorderedIsTrue, forX, forY, view);
    93         if (value != null) {
    94         if (value != null) {
    94             return value;
    95             return value;
    95         }
    96         }
    96         return this;
    97         return this;
    97     }
    98     }
    98 
    99 
    99     public static class FloatEqualsOp extends CompareOp {
   100     public static class FloatEqualsOp extends CompareOp {
   100 
   101 
   101         @Override
   102         @Override
   102         public LogicNode canonical(ConstantReflectionProvider constantReflection, MetaAccessProvider metaAccess, OptionValues options, Integer smallestCompareWidth, Condition condition,
   103         public LogicNode canonical(ConstantReflectionProvider constantReflection, MetaAccessProvider metaAccess, OptionValues options, Integer smallestCompareWidth, CanonicalCondition condition,
   103                         boolean unorderedIsTrue, ValueNode forX, ValueNode forY, NodeView view) {
   104                         boolean unorderedIsTrue, ValueNode forX, ValueNode forY, NodeView view) {
   104             LogicNode result = super.canonical(constantReflection, metaAccess, options, smallestCompareWidth, condition, unorderedIsTrue, forX, forY, view);
   105             LogicNode result = super.canonical(constantReflection, metaAccess, options, smallestCompareWidth, condition, unorderedIsTrue, forX, forY, view);
   105             if (result != null) {
   106             if (result != null) {
   106                 return result;
   107                 return result;
   107             }
   108             }