Commit 7089442cb6214a46b1476d18d068f8b2972d1b22
1 parent
f6503059
Fix andi, optimize addi and subi zero cases
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3985 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
13 additions
and
3 deletions
tcg/tcg-op.h
| ... | ... | @@ -252,7 +252,12 @@ static inline void tcg_gen_add_i32(TCGv ret, TCGv arg1, TCGv arg2) |
| 252 | 252 | |
| 253 | 253 | static inline void tcg_gen_addi_i32(TCGv ret, TCGv arg1, int32_t arg2) |
| 254 | 254 | { |
| 255 | - tcg_gen_add_i32(ret, arg1, tcg_const_i32(arg2)); | |
| 255 | + /* some cases can be optimized here */ | |
| 256 | + if (arg2 == 0) { | |
| 257 | + tcg_gen_mov_i32(ret, arg1); | |
| 258 | + } else { | |
| 259 | + tcg_gen_add_i32(ret, arg1, tcg_const_i32(arg2)); | |
| 260 | + } | |
| 256 | 261 | } |
| 257 | 262 | |
| 258 | 263 | static inline void tcg_gen_sub_i32(TCGv ret, TCGv arg1, TCGv arg2) |
| ... | ... | @@ -262,7 +267,12 @@ static inline void tcg_gen_sub_i32(TCGv ret, TCGv arg1, TCGv arg2) |
| 262 | 267 | |
| 263 | 268 | static inline void tcg_gen_subi_i32(TCGv ret, TCGv arg1, int32_t arg2) |
| 264 | 269 | { |
| 265 | - tcg_gen_sub_i32(ret, arg1, tcg_const_i32(arg2)); | |
| 270 | + /* some cases can be optimized here */ | |
| 271 | + if (arg2 == 0) { | |
| 272 | + tcg_gen_mov_i32(ret, arg1); | |
| 273 | + } else { | |
| 274 | + tcg_gen_sub_i32(ret, arg1, tcg_const_i32(arg2)); | |
| 275 | + } | |
| 266 | 276 | } |
| 267 | 277 | |
| 268 | 278 | static inline void tcg_gen_and_i32(TCGv ret, TCGv arg1, TCGv arg2) |
| ... | ... | @@ -291,7 +301,7 @@ static inline void tcg_gen_ori_i32(TCGv ret, TCGv arg1, int32_t arg2) |
| 291 | 301 | { |
| 292 | 302 | /* some cases can be optimized here */ |
| 293 | 303 | if (arg2 == 0xffffffff) { |
| 294 | - tcg_gen_movi_i32(ret, 0); | |
| 304 | + tcg_gen_movi_i32(ret, 0xffffffff); | |
| 295 | 305 | } else if (arg2 == 0) { |
| 296 | 306 | tcg_gen_mov_i32(ret, arg1); |
| 297 | 307 | } else { | ... | ... |