Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/subnode.cpp @ 3416:f88fb2fa90cf
6956668: misbehavior of XOR operator (^) with int
Summary: optimize cmp_ne(xor(X,1),0) to cmp_eq(X,0) only for boolean values X.
Reviewed-by: never
author | kvn |
---|---|
date | Tue, 31 May 2011 10:05:36 -0700 |
parents | f1d6640088a1 |
children | 35acf8f0a2e4 |
comparison
equal
deleted
inserted
replaced
3415:7c907a50c1bb | 3416:f88fb2fa90cf |
---|---|
1099 if (cmp2_type == NULL) return NULL; | 1099 if (cmp2_type == NULL) return NULL; |
1100 Node* j_xor = cmp1; | 1100 Node* j_xor = cmp1; |
1101 if( cmp2_type == TypeInt::ZERO && | 1101 if( cmp2_type == TypeInt::ZERO && |
1102 cmp1_op == Op_XorI && | 1102 cmp1_op == Op_XorI && |
1103 j_xor->in(1) != j_xor && // An xor of itself is dead | 1103 j_xor->in(1) != j_xor && // An xor of itself is dead |
1104 phase->type( j_xor->in(1) ) == TypeInt::BOOL && | |
1104 phase->type( j_xor->in(2) ) == TypeInt::ONE && | 1105 phase->type( j_xor->in(2) ) == TypeInt::ONE && |
1105 (_test._test == BoolTest::eq || | 1106 (_test._test == BoolTest::eq || |
1106 _test._test == BoolTest::ne) ) { | 1107 _test._test == BoolTest::ne) ) { |
1107 Node *ncmp = phase->transform(new (phase->C, 3) CmpINode(j_xor->in(1),cmp2)); | 1108 Node *ncmp = phase->transform(new (phase->C, 3) CmpINode(j_xor->in(1),cmp2)); |
1108 return new (phase->C, 2) BoolNode( ncmp, _test.negate() ); | 1109 return new (phase->C, 2) BoolNode( ncmp, _test.negate() ); |