92 LogicNode value = OP.canonical(constantReflection, metaAccess, options, smallestCompareWidth, CanonicalCondition.EQ, false, x, y, view);
93 if (value != null) {
94 return value;
95 }
96 return create(x, y, view);
97 }
98
99 @Override
100 public Node canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
101 NodeView view = NodeView.from(tool);
102 ValueNode value = OP.canonical(tool.getConstantReflection(), tool.getMetaAccess(), tool.getOptions(), tool.smallestCompareWidth(), CanonicalCondition.EQ, false, forX, forY, view);
103 if (value != null) {
104 return value;
105 }
106 return this;
107 }
108
109 public static class IntegerEqualsOp extends CompareOp {
110 @Override
111 protected LogicNode optimizeNormalizeCompare(ConstantReflectionProvider constantReflection, MetaAccessProvider metaAccess, OptionValues options, Integer smallestCompareWidth,
112 Constant constant, NormalizeCompareNode normalizeNode, boolean mirrored, NodeView view) {
113 PrimitiveConstant primitive = (PrimitiveConstant) constant;
114 ValueNode a = normalizeNode.getX();
115 ValueNode b = normalizeNode.getY();
116 long cst = primitive.asLong();
117
118 if (cst == 0) {
119 if (normalizeNode.getX().getStackKind() == JavaKind.Double || normalizeNode.getX().getStackKind() == JavaKind.Float) {
120 return FloatEqualsNode.create(constantReflection, metaAccess, options, smallestCompareWidth, a, b, view);
121 } else {
122 return IntegerEqualsNode.create(constantReflection, metaAccess, options, smallestCompareWidth, a, b, view);
123 }
124 } else if (cst == 1) {
125 if (normalizeNode.getX().getStackKind() == JavaKind.Double || normalizeNode.getX().getStackKind() == JavaKind.Float) {
126 return FloatLessThanNode.create(b, a, !normalizeNode.isUnorderedLess, view);
127 } else {
128 return IntegerLessThanNode.create(constantReflection, metaAccess, options, smallestCompareWidth, b, a, view);
129 }
130 } else if (cst == -1) {
131 if (normalizeNode.getX().getStackKind() == JavaKind.Double || normalizeNode.getX().getStackKind() == JavaKind.Float) {
132 return FloatLessThanNode.create(a, b, normalizeNode.isUnorderedLess, view);
133 } else {
134 return IntegerLessThanNode.create(constantReflection, metaAccess, options, smallestCompareWidth, a, b, view);
135 }
136 } else {
137 return LogicConstantNode.contradiction();
138 }
139 }
140
141 @Override
142 protected CompareNode duplicateModified(ValueNode newX, ValueNode newY, boolean unorderedIsTrue, NodeView view) {
143 if (newX.stamp(view) instanceof FloatStamp && newY.stamp(view) instanceof FloatStamp) {
144 return new FloatEqualsNode(newX, newY);
145 } else if (newX.stamp(view) instanceof IntegerStamp && newY.stamp(view) instanceof IntegerStamp) {
146 return new IntegerEqualsNode(newX, newY);
147 } else if (newX.stamp(view) instanceof AbstractPointerStamp && newY.stamp(view) instanceof AbstractPointerStamp) {
148 return new IntegerEqualsNode(newX, newY);
149 }
150 throw GraalError.shouldNotReachHere();
151 }
152
153 @Override
154 public LogicNode canonical(ConstantReflectionProvider constantReflection, MetaAccessProvider metaAccess, OptionValues options, Integer smallestCompareWidth, CanonicalCondition condition,
155 boolean unorderedIsTrue, ValueNode forX, ValueNode forY, NodeView view) {
|
92 LogicNode value = OP.canonical(constantReflection, metaAccess, options, smallestCompareWidth, CanonicalCondition.EQ, false, x, y, view);
93 if (value != null) {
94 return value;
95 }
96 return create(x, y, view);
97 }
98
99 @Override
100 public Node canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
101 NodeView view = NodeView.from(tool);
102 ValueNode value = OP.canonical(tool.getConstantReflection(), tool.getMetaAccess(), tool.getOptions(), tool.smallestCompareWidth(), CanonicalCondition.EQ, false, forX, forY, view);
103 if (value != null) {
104 return value;
105 }
106 return this;
107 }
108
109 public static class IntegerEqualsOp extends CompareOp {
110 @Override
111 protected LogicNode optimizeNormalizeCompare(ConstantReflectionProvider constantReflection, MetaAccessProvider metaAccess, OptionValues options, Integer smallestCompareWidth,
112 Constant constant, AbstractNormalizeCompareNode normalizeNode, boolean mirrored, NodeView view) {
113 PrimitiveConstant primitive = (PrimitiveConstant) constant;
114 long cst = primitive.asLong();
115 if (cst == 0) {
116 return normalizeNode.createEqualComparison(constantReflection, metaAccess, options, smallestCompareWidth, view);
117 } else if (cst == 1) {
118 return normalizeNode.createLowerComparison(true, constantReflection, metaAccess, options, smallestCompareWidth, view);
119 } else if (cst == -1) {
120 return normalizeNode.createLowerComparison(false, constantReflection, metaAccess, options, smallestCompareWidth, view);
121 } else {
122 return LogicConstantNode.contradiction();
123 }
124 }
125
126 @Override
127 protected CompareNode duplicateModified(ValueNode newX, ValueNode newY, boolean unorderedIsTrue, NodeView view) {
128 if (newX.stamp(view) instanceof FloatStamp && newY.stamp(view) instanceof FloatStamp) {
129 return new FloatEqualsNode(newX, newY);
130 } else if (newX.stamp(view) instanceof IntegerStamp && newY.stamp(view) instanceof IntegerStamp) {
131 return new IntegerEqualsNode(newX, newY);
132 } else if (newX.stamp(view) instanceof AbstractPointerStamp && newY.stamp(view) instanceof AbstractPointerStamp) {
133 return new IntegerEqualsNode(newX, newY);
134 }
135 throw GraalError.shouldNotReachHere();
136 }
137
138 @Override
139 public LogicNode canonical(ConstantReflectionProvider constantReflection, MetaAccessProvider metaAccess, OptionValues options, Integer smallestCompareWidth, CanonicalCondition condition,
140 boolean unorderedIsTrue, ValueNode forX, ValueNode forY, NodeView view) {
|