1109 Node* cmov = CMoveNode::make(phase->C, NULL, this,
1110 phase->intcon(0), phase->intcon(1),
1111 TypeInt::BOOL);
1112 return phase->transform(cmov);
1113 }
1114
1115 //----------------------------------negate-------------------------------------
1116 BoolNode* BoolNode::negate(PhaseGVN* phase) {
1117 Compile* C = phase->C;
1118 return new (C) BoolNode(in(1), _test.negate());
1119 }
1120
1121
1122 //------------------------------Ideal------------------------------------------
1123 Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1124 // Change "bool tst (cmp con x)" into "bool ~tst (cmp x con)".
1125 // This moves the constant to the right. Helps value-numbering.
1126 Node *cmp = in(1);
1127 if( !cmp->is_Sub() ) return NULL;
1128 int cop = cmp->Opcode();
1129 if( cop == Op_FastLock || cop == Op_FastUnlock || cop == Op_FlagsProj) return NULL;
1130 Node *cmp1 = cmp->in(1);
1131 Node *cmp2 = cmp->in(2);
1132 if( !cmp1 ) return NULL;
1133
1134 // Constant on left?
1135 Node *con = cmp1;
1136 uint op2 = cmp2->Opcode();
1137 // Move constants to the right of compare's to canonicalize.
1138 // Do not muck with Opaque1 nodes, as this indicates a loop
1139 // guard that cannot change shape.
1140 if( con->is_Con() && !cmp2->is_Con() && op2 != Op_Opaque1 &&
1141 // Because of NaN's, CmpD and CmpF are not commutative
1142 cop != Op_CmpD && cop != Op_CmpF &&
1143 // Protect against swapping inputs to a compare when it is used by a
1144 // counted loop exit, which requires maintaining the loop-limit as in(2)
1145 !is_counted_loop_exit_test() ) {
1146 // Ok, commute the constant to the right of the cmp node.
1147 // Clone the Node, getting a new Node of the same class
1148 cmp = cmp->clone();
1149 // Swap inputs to the clone
1150 cmp->swap_edges(1, 2);
1151 cmp = phase->transform( cmp );
1152 return new (phase->C) BoolNode( cmp, _test.commute() );
|
1109 Node* cmov = CMoveNode::make(phase->C, NULL, this,
1110 phase->intcon(0), phase->intcon(1),
1111 TypeInt::BOOL);
1112 return phase->transform(cmov);
1113 }
1114
1115 //----------------------------------negate-------------------------------------
1116 BoolNode* BoolNode::negate(PhaseGVN* phase) {
1117 Compile* C = phase->C;
1118 return new (C) BoolNode(in(1), _test.negate());
1119 }
1120
1121
1122 //------------------------------Ideal------------------------------------------
1123 Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1124 // Change "bool tst (cmp con x)" into "bool ~tst (cmp x con)".
1125 // This moves the constant to the right. Helps value-numbering.
1126 Node *cmp = in(1);
1127 if( !cmp->is_Sub() ) return NULL;
1128 int cop = cmp->Opcode();
1129 if( cop == Op_FastLock || cop == Op_FastUnlock) return NULL;
1130 Node *cmp1 = cmp->in(1);
1131 Node *cmp2 = cmp->in(2);
1132 if( !cmp1 ) return NULL;
1133
1134 if (_test._test == BoolTest::overflow || _test._test == BoolTest::no_overflow) {
1135 return NULL;
1136 }
1137
1138 // Constant on left?
1139 Node *con = cmp1;
1140 uint op2 = cmp2->Opcode();
1141 // Move constants to the right of compare's to canonicalize.
1142 // Do not muck with Opaque1 nodes, as this indicates a loop
1143 // guard that cannot change shape.
1144 if( con->is_Con() && !cmp2->is_Con() && op2 != Op_Opaque1 &&
1145 // Because of NaN's, CmpD and CmpF are not commutative
1146 cop != Op_CmpD && cop != Op_CmpF &&
1147 // Protect against swapping inputs to a compare when it is used by a
1148 // counted loop exit, which requires maintaining the loop-limit as in(2)
1149 !is_counted_loop_exit_test() ) {
1150 // Ok, commute the constant to the right of the cmp node.
1151 // Clone the Node, getting a new Node of the same class
1152 cmp = cmp->clone();
1153 // Swap inputs to the clone
1154 cmp->swap_edges(1, 2);
1155 cmp = phase->transform( cmp );
1156 return new (phase->C) BoolNode( cmp, _test.commute() );
|