Commit affa3264db0fa0508d3fe9755592a21f48cc077e
1 parent
0a6b7b78
jump optimizations
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4582 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
9 additions
and
31 deletions
tcg/i386/tcg-target.c
| ... | ... | @@ -40,7 +40,6 @@ int tcg_target_reg_alloc_order[] = { |
| 40 | 40 | TCG_REG_ESI, |
| 41 | 41 | TCG_REG_EDI, |
| 42 | 42 | TCG_REG_EBP, |
| 43 | - TCG_REG_ESP, | |
| 44 | 43 | }; |
| 45 | 44 | |
| 46 | 45 | const int tcg_target_call_iarg_regs[3] = { TCG_REG_EAX, TCG_REG_EDX, TCG_REG_ECX }; |
| ... | ... | @@ -329,38 +328,17 @@ static void tcg_out_brcond(TCGContext *s, int cond, |
| 329 | 328 | TCGArg arg1, TCGArg arg2, int const_arg2, |
| 330 | 329 | int label_index) |
| 331 | 330 | { |
| 332 | - int c; | |
| 333 | 331 | if (const_arg2) { |
| 334 | 332 | if (arg2 == 0) { |
| 335 | - /* use test */ | |
| 336 | - switch(cond) { | |
| 337 | - case TCG_COND_EQ: | |
| 338 | - c = JCC_JE; | |
| 339 | - break; | |
| 340 | - case TCG_COND_NE: | |
| 341 | - c = JCC_JNE; | |
| 342 | - break; | |
| 343 | - case TCG_COND_LT: | |
| 344 | - c = JCC_JS; | |
| 345 | - break; | |
| 346 | - case TCG_COND_GE: | |
| 347 | - c = JCC_JNS; | |
| 348 | - break; | |
| 349 | - default: | |
| 350 | - goto do_cmpi; | |
| 351 | - } | |
| 352 | 333 | /* test r, r */ |
| 353 | 334 | tcg_out_modrm(s, 0x85, arg1, arg1); |
| 354 | - tcg_out_jxx(s, c, label_index); | |
| 355 | 335 | } else { |
| 356 | - do_cmpi: | |
| 357 | 336 | tgen_arithi(s, ARITH_CMP, arg1, arg2); |
| 358 | - tcg_out_jxx(s, tcg_cond_to_jcc[cond], label_index); | |
| 359 | 337 | } |
| 360 | 338 | } else { |
| 361 | 339 | tcg_out_modrm(s, 0x01 | (ARITH_CMP << 3), arg2, arg1); |
| 362 | - tcg_out_jxx(s, tcg_cond_to_jcc[cond], label_index); | |
| 363 | 340 | } |
| 341 | + tcg_out_jxx(s, tcg_cond_to_jcc[cond], label_index); | |
| 364 | 342 | } |
| 365 | 343 | |
| 366 | 344 | /* XXX: we implement it at the target level to avoid having to |
| ... | ... | @@ -381,42 +359,42 @@ static void tcg_out_brcond2(TCGContext *s, |
| 381 | 359 | break; |
| 382 | 360 | case TCG_COND_LT: |
| 383 | 361 | tcg_out_brcond(s, TCG_COND_LT, args[1], args[3], const_args[3], args[5]); |
| 384 | - tcg_out_brcond(s, TCG_COND_NE, args[1], args[3], const_args[3], label_next); | |
| 362 | + tcg_out_jxx(s, JCC_JNE, label_next); | |
| 385 | 363 | tcg_out_brcond(s, TCG_COND_LT, args[0], args[2], const_args[2], args[5]); |
| 386 | 364 | break; |
| 387 | 365 | case TCG_COND_LE: |
| 388 | 366 | tcg_out_brcond(s, TCG_COND_LT, args[1], args[3], const_args[3], args[5]); |
| 389 | - tcg_out_brcond(s, TCG_COND_NE, args[1], args[3], const_args[3], label_next); | |
| 367 | + tcg_out_jxx(s, JCC_JNE, label_next); | |
| 390 | 368 | tcg_out_brcond(s, TCG_COND_LE, args[0], args[2], const_args[2], args[5]); |
| 391 | 369 | break; |
| 392 | 370 | case TCG_COND_GT: |
| 393 | 371 | tcg_out_brcond(s, TCG_COND_GT, args[1], args[3], const_args[3], args[5]); |
| 394 | - tcg_out_brcond(s, TCG_COND_NE, args[1], args[3], const_args[3], label_next); | |
| 372 | + tcg_out_jxx(s, JCC_JNE, label_next); | |
| 395 | 373 | tcg_out_brcond(s, TCG_COND_GT, args[0], args[2], const_args[2], args[5]); |
| 396 | 374 | break; |
| 397 | 375 | case TCG_COND_GE: |
| 398 | 376 | tcg_out_brcond(s, TCG_COND_GT, args[1], args[3], const_args[3], args[5]); |
| 399 | - tcg_out_brcond(s, TCG_COND_NE, args[1], args[3], const_args[3], label_next); | |
| 377 | + tcg_out_jxx(s, JCC_JNE, label_next); | |
| 400 | 378 | tcg_out_brcond(s, TCG_COND_GE, args[0], args[2], const_args[2], args[5]); |
| 401 | 379 | break; |
| 402 | 380 | case TCG_COND_LTU: |
| 403 | 381 | tcg_out_brcond(s, TCG_COND_LTU, args[1], args[3], const_args[3], args[5]); |
| 404 | - tcg_out_brcond(s, TCG_COND_NE, args[1], args[3], const_args[3], label_next); | |
| 382 | + tcg_out_jxx(s, JCC_JNE, label_next); | |
| 405 | 383 | tcg_out_brcond(s, TCG_COND_LTU, args[0], args[2], const_args[2], args[5]); |
| 406 | 384 | break; |
| 407 | 385 | case TCG_COND_LEU: |
| 408 | 386 | tcg_out_brcond(s, TCG_COND_LTU, args[1], args[3], const_args[3], args[5]); |
| 409 | - tcg_out_brcond(s, TCG_COND_NE, args[1], args[3], const_args[3], label_next); | |
| 387 | + tcg_out_jxx(s, JCC_JNE, label_next); | |
| 410 | 388 | tcg_out_brcond(s, TCG_COND_LEU, args[0], args[2], const_args[2], args[5]); |
| 411 | 389 | break; |
| 412 | 390 | case TCG_COND_GTU: |
| 413 | 391 | tcg_out_brcond(s, TCG_COND_GTU, args[1], args[3], const_args[3], args[5]); |
| 414 | - tcg_out_brcond(s, TCG_COND_NE, args[1], args[3], const_args[3], label_next); | |
| 392 | + tcg_out_jxx(s, JCC_JNE, label_next); | |
| 415 | 393 | tcg_out_brcond(s, TCG_COND_GTU, args[0], args[2], const_args[2], args[5]); |
| 416 | 394 | break; |
| 417 | 395 | case TCG_COND_GEU: |
| 418 | 396 | tcg_out_brcond(s, TCG_COND_GTU, args[1], args[3], const_args[3], args[5]); |
| 419 | - tcg_out_brcond(s, TCG_COND_NE, args[1], args[3], const_args[3], label_next); | |
| 397 | + tcg_out_jxx(s, JCC_JNE, label_next); | |
| 420 | 398 | tcg_out_brcond(s, TCG_COND_GEU, args[0], args[2], const_args[2], args[5]); |
| 421 | 399 | break; |
| 422 | 400 | default: | ... | ... |