Use zero-extended load if possible

This commit is contained in:
Dmitry Stogov 2022-04-19 14:18:39 +03:00
parent 207dca73e8
commit a1366ebd92
2 changed files with 6 additions and 5 deletions

3
TODO
View File

@ -29,9 +29,6 @@
- xor, btsl=INCL, btrl=EXCL, btl=IN, bsr, maxss, maxsd, minss, minsd
- MOVZX to avoid a SHIFT and AND instruction
- Using CMOVcc to remove branches
- mov rax, 123456789abcdef0h ; 10 bytes (64-bit constant)
- mov rax, -100 ; 7 bytes (32-bit sign-extended)
- mov eax, 100 ; 5 bytes (32-bit zero-extended)
? register allocation
+ linear scan

View File

@ -187,11 +187,15 @@
| lea Ra(dst), aword [=>label]
|| _insn->emit_const = 1;
|| } else if (ir_type_size[type] == 8 && !IR_IS_SIGNED_32BIT(_insn->val.i64)) {
|| if (IR_IS_UNSIGNED_32BIT(_insn->val.u64)) {
| mov Rd(dst), _insn->val.u32 // zero extended load
|| } else {
| mov64 Ra(dst), _insn->val.i64
|| }
|| } else if (_insn->val.i64 == 0) {
| ASM_REG_REG_OP xor, type, dst, dst
|| } else {
| ASM_REG_IMM_OP mov, type, dst, _insn->val.i32
| ASM_REG_IMM_OP mov, type, dst, _insn->val.i32 // sign extended load
|| }
|| } else {
|| ir_reg _reg = ir_ref_reg(ctx, src);