hotspot Sdiff src/share/vm/opto (original) (raw)


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) or ((m & x) u<= m) to always true 1211 if ( cop == Op_CmpU && 1212 _test._test == BoolTest::le && 1213 cmp1->Opcode() == Op_AndI && 1214 (cmp1->in(2) == cmp2 || cmp1->in(1) == cmp2)) { 1215 return ConINode::make(phase->C, 1); 1216 } 1217 1218 // Change ((x & (m - 1)) u< m) into (m > 0) 1219 // This is the off-by-one variant of the above 1220 if ( cop == Op_CmpU && 1221 _test._test == BoolTest::lt && 1222 cmp1->Opcode() == Op_AndI) { 1223 Node
l = cmp1->in(1); 1224 Node
r = cmp1->in(2); 1225 for (int repeat = 0; repeat < 2; repeat++) { 1226 bool match = r->Opcode() == Op_AddI && r->in(2)->find_int_con(0) == -1 && 1227 r->in(1) == cmp2; 1228 if (match) { 1229 // arraylength known to be non-negative, so a (arraylength != 0) is sufficient, 1230 // but to be compatible with the array range check pattern, use (arraylength u> 0) 1231 Node* ncmp = cmp2->Opcode() == Op_LoadRange 1232 ? phase->transform( new (phase->C) CmpUNode(cmp2, phase->intcon(0))) 1233 : phase->transform( new (phase->C) CmpINode(cmp2, phase->intcon(0))); 1234 return new (phase->C) BoolNode(ncmp, BoolTest::gt); 1235 } else { 1236 // commute and try again 1237 l = cmp1->in(2); 1238 r = cmp1->in(1); 1239 } 1240 } 1241 } 1242
1243 // Change (arraylength <= 0) or (arraylength == 0) 1244 // into (arraylength u<= 0) 1245 // Also change (arraylength != 0) into (arraylength u> 0) 1246 // The latter version matches the code pattern generated for 1247 // array range checks, which will more likely be optimized later. 1248 if ( cop == Op_CmpI && 1249 cmp1->Opcode() == Op_LoadRange && 1250 cmp2->find_int_con(-1) == 0) { 1251 Node* ncmp = phase->transform( new (phase->C) CmpUNode(cmp1, cmp2)); 1252 if (_test._test == BoolTest::le || _test._test == BoolTest::eq) { 1253 return new (phase->C) BoolNode(ncmp, BoolTest::le); 1254 } else if (_test._test == BoolTest::ne) { 1255 return new (phase->C) BoolNode(ncmp, BoolTest::gt); 1256 } 1257 } 1258 1259 // The transformation below is not valid for either signed or unsigned 1260 // comparisons due to wraparound concerns at MAX_VALUE and MIN_VALUE. 1261 // This transformation can be resurrected when we are able to 1262 // make inferences about the range of values being subtracted from 1263 // (or added to) relative to the wraparound point. 1264 // 1265 // // Remove +/-1's if possible. 1266 // // "X <= Y-1" becomes "X < Y" 1267 // // "X+1 <= Y" becomes "X < Y" 1268 // // "X < Y+1" becomes "X <= Y" 1269 // // "X-1 < Y" becomes "X <= Y" 1270 // // Do not this to compares off of the counted-loop-end. These guys are 1271 // // checking the trip counter and they want to use the post-incremented 1272 // // counter. If they use the PRE-incremented counter, then the counter has 1273 // // to be incremented in a private block on a loop backedge. 1274 // if( du && du->cnt(this) && du->out(this)[0]->Opcode() == Op_CountedLoopEnd ) 1275 // return NULL; 1276 // #ifndef PRODUCT 1277 // // Do not do this in a wash GVN pass during verification. 1278 // // Gets triggered by too many simple optimizations to be bothered with