1151 void BoolTest::dump_on(outputStream *st) const {
1152 const char *msg[] = {"eq","gt","of","lt","ne","le","nof","ge"};
1153 st->print("%s", msg[_test]);
1154 }
1155 #endif
1156
1157 //=============================================================================
1158 uint BoolNode::hash() const { return (Node::hash() << 3)|(_test._test+1); }
1159 uint BoolNode::size_of() const { return sizeof(BoolNode); }
1160
1161 //------------------------------operator==-------------------------------------
1162 uint BoolNode::cmp( const Node &n ) const {
1163 const BoolNode *b = (const BoolNode *)&n; // Cast up
1164 return (_test._test == b->_test._test);
1165 }
1166
1167 //-------------------------------make_predicate--------------------------------
1168 Node* BoolNode::make_predicate(Node* test_value, PhaseGVN* phase) {
1169 if (test_value->is_Con()) return test_value;
1170 if (test_value->is_Bool()) return test_value;
1171 Compile* C = phase->C;
1172 if (test_value->is_CMove() &&
1173 test_value->in(CMoveNode::Condition)->is_Bool()) {
1174 BoolNode* bol = test_value->in(CMoveNode::Condition)->as_Bool();
1175 const Type* ftype = phase->type(test_value->in(CMoveNode::IfFalse));
1176 const Type* ttype = phase->type(test_value->in(CMoveNode::IfTrue));
1177 if (ftype == TypeInt::ZERO && !TypeInt::ZERO->higher_equal(ttype)) {
1178 return bol;
1179 } else if (ttype == TypeInt::ZERO && !TypeInt::ZERO->higher_equal(ftype)) {
1180 return phase->transform( bol->negate(phase) );
1181 }
1182 // Else fall through. The CMove gets in the way of the test.
1183 // It should be the case that make_predicate(bol->as_int_value()) == bol.
1184 }
1185 Node* cmp = new CmpINode(test_value, phase->intcon(0));
1186 cmp = phase->transform(cmp);
1187 Node* bol = new BoolNode(cmp, BoolTest::ne);
1188 return phase->transform(bol);
1189 }
1190
1191 //--------------------------------as_int_value---------------------------------
1192 Node* BoolNode::as_int_value(PhaseGVN* phase) {
1193 // Inverse to make_predicate. The CMove probably boils down to a Conv2B.
1194 Node* cmov = CMoveNode::make(phase->C, NULL, this,
1195 phase->intcon(0), phase->intcon(1),
1196 TypeInt::BOOL);
1197 return phase->transform(cmov);
1198 }
1199
1200 //----------------------------------negate-------------------------------------
1201 BoolNode* BoolNode::negate(PhaseGVN* phase) {
1202 Compile* C = phase->C;
1203 return new BoolNode(in(1), _test.negate());
1204 }
1205
1206
1207 //------------------------------Ideal------------------------------------------
1208 Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1209 // Change "bool tst (cmp con x)" into "bool ~tst (cmp x con)".
1210 // This moves the constant to the right. Helps value-numbering.
1211 Node *cmp = in(1);
1212 if( !cmp->is_Sub() ) return NULL;
1213 int cop = cmp->Opcode();
1214 if( cop == Op_FastLock || cop == Op_FastUnlock) return NULL;
1215 Node *cmp1 = cmp->in(1);
1216 Node *cmp2 = cmp->in(2);
1217 if( !cmp1 ) return NULL;
1218
1219 if (_test._test == BoolTest::overflow || _test._test == BoolTest::no_overflow) {
1220 return NULL;
1221 }
1222
|
1151 void BoolTest::dump_on(outputStream *st) const {
1152 const char *msg[] = {"eq","gt","of","lt","ne","le","nof","ge"};
1153 st->print("%s", msg[_test]);
1154 }
1155 #endif
1156
1157 //=============================================================================
1158 uint BoolNode::hash() const { return (Node::hash() << 3)|(_test._test+1); }
1159 uint BoolNode::size_of() const { return sizeof(BoolNode); }
1160
1161 //------------------------------operator==-------------------------------------
1162 uint BoolNode::cmp( const Node &n ) const {
1163 const BoolNode *b = (const BoolNode *)&n; // Cast up
1164 return (_test._test == b->_test._test);
1165 }
1166
1167 //-------------------------------make_predicate--------------------------------
1168 Node* BoolNode::make_predicate(Node* test_value, PhaseGVN* phase) {
1169 if (test_value->is_Con()) return test_value;
1170 if (test_value->is_Bool()) return test_value;
1171 if (test_value->is_CMove() &&
1172 test_value->in(CMoveNode::Condition)->is_Bool()) {
1173 BoolNode* bol = test_value->in(CMoveNode::Condition)->as_Bool();
1174 const Type* ftype = phase->type(test_value->in(CMoveNode::IfFalse));
1175 const Type* ttype = phase->type(test_value->in(CMoveNode::IfTrue));
1176 if (ftype == TypeInt::ZERO && !TypeInt::ZERO->higher_equal(ttype)) {
1177 return bol;
1178 } else if (ttype == TypeInt::ZERO && !TypeInt::ZERO->higher_equal(ftype)) {
1179 return phase->transform( bol->negate(phase) );
1180 }
1181 // Else fall through. The CMove gets in the way of the test.
1182 // It should be the case that make_predicate(bol->as_int_value()) == bol.
1183 }
1184 Node* cmp = new CmpINode(test_value, phase->intcon(0));
1185 cmp = phase->transform(cmp);
1186 Node* bol = new BoolNode(cmp, BoolTest::ne);
1187 return phase->transform(bol);
1188 }
1189
1190 //--------------------------------as_int_value---------------------------------
1191 Node* BoolNode::as_int_value(PhaseGVN* phase) {
1192 // Inverse to make_predicate. The CMove probably boils down to a Conv2B.
1193 Node* cmov = CMoveNode::make(NULL, this,
1194 phase->intcon(0), phase->intcon(1),
1195 TypeInt::BOOL);
1196 return phase->transform(cmov);
1197 }
1198
1199 //----------------------------------negate-------------------------------------
1200 BoolNode* BoolNode::negate(PhaseGVN* phase) {
1201 return new BoolNode(in(1), _test.negate());
1202 }
1203
1204
1205 //------------------------------Ideal------------------------------------------
1206 Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1207 // Change "bool tst (cmp con x)" into "bool ~tst (cmp x con)".
1208 // This moves the constant to the right. Helps value-numbering.
1209 Node *cmp = in(1);
1210 if( !cmp->is_Sub() ) return NULL;
1211 int cop = cmp->Opcode();
1212 if( cop == Op_FastLock || cop == Op_FastUnlock) return NULL;
1213 Node *cmp1 = cmp->in(1);
1214 Node *cmp2 = cmp->in(2);
1215 if( !cmp1 ) return NULL;
1216
1217 if (_test._test == BoolTest::overflow || _test._test == BoolTest::no_overflow) {
1218 return NULL;
1219 }
1220
|