Skip to content

Commit fd25d5b

Browse files
author
Eric Liu
committed
Implements Value() for XorNode.
Change-Id: Ic9fc01375801adc82c0a0289d9a11a5367031eb4
1 parent 7e1588c commit fd25d5b

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

src/hotspot/share/opto/addnode.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -914,16 +914,19 @@ const Type *OrLNode::add_ring( const Type *t0, const Type *t1 ) const {
914914

915915
//=============================================================================
916916

917-
Node* XorINode::Ideal(PhaseGVN* phase, bool can_reshape) {
917+
const Type* XorINode::Value(PhaseGVN* phase) const {
918918
Node* in1 = in(1);
919919
Node* in2 = in(2);
920920
const Type* t1 = phase->type(in1);
921921
const Type* t2 = phase->type(in2);
922-
if (t1 != Type::TOP && t2 != Type::TOP && in1 == in2) {
923-
return new ConINode(TypeInt::ZERO);
922+
if (t1 == Type::TOP || t2 == Type::TOP) {
923+
return Type::TOP;
924924
}
925-
926-
return AddNode::Ideal(phase, can_reshape);
925+
// x ^ x ==> 0
926+
if (in1->eqv_uncast(in2)) {
927+
return add_id();
928+
}
929+
return AddNode::Value(phase);
927930
}
928931

929932
//------------------------------add_ring---------------------------------------
@@ -961,15 +964,19 @@ const Type *XorLNode::add_ring( const Type *t0, const Type *t1 ) const {
961964
return TypeLong::make( r0->get_con() ^ r1->get_con() );
962965
}
963966

964-
Node* XorLNode::Ideal(PhaseGVN* phase, bool can_reshape) {
967+
const Type* XorLNode::Value(PhaseGVN* phase) const {
965968
Node* in1 = in(1);
966969
Node* in2 = in(2);
967970
const Type* t1 = phase->type(in1);
968971
const Type* t2 = phase->type(in2);
969-
if (t1 != Type::TOP && t2 != Type::TOP && in1 == in2) {
970-
return new ConLNode(TypeLong::ZERO);
972+
if (t1 == Type::TOP || t2 == Type::TOP) {
973+
return Type::TOP;
971974
}
972-
return AddNode::Ideal(phase, can_reshape);
975+
// x ^ x ==> 0
976+
if (in1->eqv_uncast(in2)) {
977+
return add_id();
978+
}
979+
return AddNode::Value(phase);
973980
}
974981

975982
Node* MaxNode::build_min_max(Node* a, Node* b, bool is_max, bool is_unsigned, const Type* t, PhaseGVN& gvn) {

src/hotspot/share/opto/addnode.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ class XorINode : public AddNode {
212212
virtual const Type *add_ring( const Type *, const Type * ) const;
213213
virtual const Type *add_id() const { return TypeInt::ZERO; }
214214
virtual const Type *bottom_type() const { return TypeInt::INT; }
215+
virtual const Type *Value(PhaseGVN *phase) const;
215216
virtual uint ideal_reg() const { return Op_RegI; }
216-
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
217217
};
218218

219219
//------------------------------XorINode---------------------------------------
@@ -225,8 +225,8 @@ class XorLNode : public AddNode {
225225
virtual const Type *add_ring( const Type *, const Type * ) const;
226226
virtual const Type *add_id() const { return TypeLong::ZERO; }
227227
virtual const Type *bottom_type() const { return TypeLong::LONG; }
228+
virtual const Type *Value(PhaseGVN *phase) const;
228229
virtual uint ideal_reg() const { return Op_RegL; }
229-
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
230230
};
231231

232232
//------------------------------MaxNode----------------------------------------

0 commit comments

Comments
 (0)