1190 if ((_test._test == BoolTest::eq || _test._test == BoolTest::ne) && 1191 (cop == Op_CmpI) && 1192 (cmp1->Opcode() == Op_SubI) && 1193 ( cmp2_type == TypeInt::ZERO ) ) { 1194 Node *ncmp = phase->transform( new (phase->C) CmpINode(cmp1->in(1),cmp1->in(2))); 1195 return new (phase->C) BoolNode( ncmp, _test._test ); 1196 } 1197 1198 // Change (-A vs 0) into (A vs 0) by commuting the test. Disallow in the 1199 // most general case because negating 0x80000000 does nothing. Needed for 1200 // the CmpF3/SubI/CmpI idiom. 1201 if( cop == Op_CmpI && 1202 cmp1->Opcode() == Op_SubI && 1203 cmp2_type == TypeInt::ZERO && 1204 phase->type( cmp1->in(1) ) == TypeInt::ZERO && 1205 phase->type( cmp1->in(2) )->higher_equal(TypeInt::SYMINT) ) { 1206 Node *ncmp = phase->transform( new (phase->C) CmpINode(cmp1->in(2),cmp2)); 1207 return new (phase->C) BoolNode( ncmp, _test.commute() ); 1208 } 1209 1210 // The transformation below is not valid for either signed or unsigned 1211 // comparisons due to wraparound concerns at MAX_VALUE and MIN_VALUE. 1212 // This transformation can be resurrected when we are able to 1213 // make inferences about the range of values being subtracted from 1214 // (or added to) relative to the wraparound point. 1215 // 1216 // // Remove +/-1's if possible. 1217 // // "X <= Y-1" becomes "X < Y" 1218 // // "X+1 <= Y" becomes "X < Y" 1219 // // "X < Y+1" becomes "X <= Y" 1220 // // "X-1 < Y" becomes "X <= Y" 1221 // // Do not this to compares off of the counted-loop-end. These guys are 1222 // // checking the trip counter and they want to use the post-incremented 1223 // // counter. If they use the PRE-incremented counter, then the counter has 1224 // // to be incremented in a private block on a loop backedge. 1225 // if( du && du->cnt(this) && du->out(this)[0]->Opcode() == Op_CountedLoopEnd ) 1226 // return NULL; 1227 // #ifndef PRODUCT 1228 // // Do not do this in a wash GVN pass during verification. 1229 // // Gets triggered by too many simple optimizations to be bothered with | 1190 if ((_test._test == BoolTest::eq || _test._test == BoolTest::ne) && 1191 (cop == Op_CmpI) && 1192 (cmp1->Opcode() == Op_SubI) && 1193 ( cmp2_type == TypeInt::ZERO ) ) { 1194 Node *ncmp = phase->transform( new (phase->C) CmpINode(cmp1->in(1),cmp1->in(2))); 1195 return new (phase->C) BoolNode( ncmp, _test._test ); 1196 } 1197 1198 // Change (-A vs 0) into (A vs 0) by commuting the test. Disallow in the 1199 // most general case because negating 0x80000000 does nothing. Needed for 1200 // the CmpF3/SubI/CmpI idiom. 1201 if( cop == Op_CmpI && 1202 cmp1->Opcode() == Op_SubI && 1203 cmp2_type == TypeInt::ZERO && 1204 phase->type( cmp1->in(1) ) == TypeInt::ZERO && 1205 phase->type( cmp1->in(2) )->higher_equal(TypeInt::SYMINT) ) { 1206 Node *ncmp = phase->transform( new (phase->C) CmpINode(cmp1->in(2),cmp2)); 1207 return new (phase->C) BoolNode( ncmp, _test.commute() ); 1208 } 1209 1210 // Change ((x & m) u<= m) to always true 1211 // Integer expressions which perform bitwise and can be proven to 1212 // be less than or equal (unsigned) to either operand, as long as the 1213 // compared operand is non-negative. 1214 if ( cop == Op_CmpU && 1215 _test._test == BoolTest::le && 1216 cmp1->Opcode() == Op_AndI && 1217 cmp1->in(2) == cmp2) { 1218 return ConINode::make(phase->C, 1); 1219 } 1220 1221 // Change ((x & m - 1) u< m) into (m > 0) 1222 // This is the off-by-one variant of the above 1223 if ((cop == Op_CmpU || cop == Op_CmpI) && 1224 _test._test == BoolTest::lt && 1225 cmp1->Opcode() == Op_AndI && 1226 (cmp1->in(2)->Opcode() == Op_AddI && cmp1->in(2)->in(2)->find_int_con(0) == -1 || 1227 cmp1->in(2)->Opcode() == Op_SubI && cmp1->in(2)->in(2)->find_int_con(0) == 1) && 1228 cmp1->in(2)->in(1) == cmp2) { 1229 Node* ncmp = phase->transform( new (phase->C) CmpINode(cmp2, phase->intcon(0))); 1230 return cmp2->Opcode() == Op_LoadRange 1231 ? new (phase->C) BoolNode(ncmp, BoolTest::ne) // arraylength known to be non-negative 1232 : new (phase->C) BoolNode(ncmp, BoolTest::gt); 1233 } 1234 1235 // The transformation below is not valid for either signed or unsigned 1236 // comparisons due to wraparound concerns at MAX_VALUE and MIN_VALUE. 1237 // This transformation can be resurrected when we are able to 1238 // make inferences about the range of values being subtracted from 1239 // (or added to) relative to the wraparound point. 1240 // 1241 // // Remove +/-1's if possible. 1242 // // "X <= Y-1" becomes "X < Y" 1243 // // "X+1 <= Y" becomes "X < Y" 1244 // // "X < Y+1" becomes "X <= Y" 1245 // // "X-1 < Y" becomes "X <= Y" 1246 // // Do not this to compares off of the counted-loop-end. These guys are 1247 // // checking the trip counter and they want to use the post-incremented 1248 // // counter. If they use the PRE-incremented counter, then the counter has 1249 // // to be incremented in a private block on a loop backedge. 1250 // if( du && du->cnt(this) && du->out(this)[0]->Opcode() == Op_CountedLoopEnd ) 1251 // return NULL; 1252 // #ifndef PRODUCT 1253 // // Do not do this in a wash GVN pass during verification. 1254 // // Gets triggered by too many simple optimizations to be bothered with |