Repository navigation
select lea32/lea64 for add(x, shl(y, 1..3)) - #144
Merged
Merged
Conversation
Coverage
Diff CoverageDiff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
|
Coverage
Diff CoverageDiff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
x86gen.hppLines 420-430 420 X86Inst* mov64_imm64(Reg dst, X86Inst::Imm imm) {
421 return &build(X86Inst::Kind::Mov64Imm64).set_rm(dst).set_imm(imm);
422 }
423
! 424 X86Inst* lea32(Reg dst, X86Inst::Mem src) {
! 425 return &build(X86Inst::Kind::Lea32).set_reg(dst).set_rm(src);
! 426 }
427
428 X86Inst* lea64(Reg dst, X86Inst::Mem src) {
429 return &build(X86Inst::Kind::Lea64).set_reg(dst).set_rm(src);
430 }Lines 780-801 780 !base->is_named() || base->type() != type || index->type() != type) {
781 return false;
782 }
783 if (dynmatch(ShlInst, shift, index)) {
! 784 if (shift->arg(0)->type() == type) {
! 785 if (dynmatch(Const, amount, shift->arg(1))) {
! 786 if (amount->value() >= 1 && amount->value() <= 3) {
! 787 X86Inst::Mem mem(vreg(base), size_t(1) << amount->value(), vreg(shift->arg(0)), 0);
! 788 if (type == Type::Int32) {
! 789 _builder.lea32(dst, mem);
! 790 } else {
! 791 _builder.lea64(dst, mem);
! 792 }
! 793 return true;
! 794 }
! 795 }
! 796 }
! 797 }
798 return false;
799 }
800
801 void build_add(Reg dst, Value* a, Value* b) {Lines 1130-1139 1130 build_add(vreg(inst), add_ptr->ptr(), add_ptr->offset());
1131 } else if (dynmatch(AddInst, add, inst)) {
1132 if (build_scaled_add(vreg(inst), add->type(), add->arg(0), add->arg(1)) ||
1133 build_scaled_add(vreg(inst), add->type(), add->arg(1), add->arg(0))) {
! 1134 return;
! 1135 }
1136 build_add(vreg(inst), add->arg(0), add->ar
8000
g(1));
1137 } else if (dynmatch(SubInst, sub, inst)) {
1138 _builder.mov64(vreg(inst), vreg(sub->arg(0)));x86insts.inc.hppLines 77-85 77
78 binop_x86_inst(MovZX8To64, movzx8to64, mov_usedef, false, { rex_w(); byte(0x0f); byte(0xb6); modrm(); })
79 binop_x86_inst(MovZX16To64, movzx16to64, mov_usedef, false, { rex_w(); byte(0x0f); byte(0xb7); modrm(); })
80
! 81 x86_inst(Lea32, lea32, { use(rm); def(reg); }, false, { rex_opt(); byte(0x8d); modrm(); })
82 x86_inst(Lea64, lea64, { use(rm); def(reg); }, true, { rex_w(); byte(0x8d); modrm(); })
83
84 binop_x86_inst(Add64, add64, binop_usedef, true, { rex_w(); byte(0x03); modrm(); })
85 binop_x86_inst(Sub64, sub64, binop_usedef, true, { rex_w(); byte(0x2b); modrm(); }) |
Coverage
Diff CoverageDiff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
x86gen.hppLines 420-430 420 X86Inst* mov64_imm64(Reg dst, X86Inst::Imm imm) {
421 return &build(X86Inst::Kind::Mov64Imm64).set_rm(dst).set_imm(imm);
422 }
423
! 424 X86Inst* lea32(Reg dst, X86Inst::Mem src) {
! 425 return &build(X86Inst::Kind::Lea32).set_reg(dst).set_rm(src);
! 426 }
427
428 X86Inst* lea64(Reg dst, X86Inst::Mem src) {
429 return &build(X86Inst::Kind::Lea64).set_reg(dst).set_rm(src);
430 }Lines 782-805 782 if (!base->is_named() || base->type() != type || index->type() != type) {
783 continue;
784 }
785 if (dynmatch(ShlInst, shift, index)) {
! 786 if (shift->arg(0)->type() != type) {
! 787 continue;
! 788 }
! 789 if (dynmatch(Const, amount, shift->arg(1))) {
! 790 if (amount->value() < 1 || amount->value() > 3) {
! 791 continue;
! 792 }
! 793 X86Inst::Mem mem(vreg(base), size_t(1) << amount->value(), vreg(shift->arg(0)), 0);
! 794 if (type == Type::Int32) {
! 795 _builder.lea32(dst, mem);
! 796 } else {
! 797 _builder.lea64(dst, mem);
! 798 }
! 799 return;
! 800 }
! 801 }
802 }
803 }
804 X86Inst::Mem mem;
805 if (dynmatch(Const, constant_b, b)) {x86insts.inc.hppLines 77-85 77
78 binop_x86_inst(MovZX8To64, movzx8to64, mov_usedef, false, { rex_w(); byte(0x0f); byte(0xb6); modrm(); })
79 binop_x86_inst(MovZX16To64, movzx16to64, mov_usedef, false, { rex_w(); byte(0x0f); byte(0xb7); modrm(); })
80
! 81 x86_inst(Lea32, lea32, { use(rm); def(reg); }, false, { rex_opt(); byte(0x8d); modrm(); })
82 x86_inst(Lea64, lea64, { use(rm); def(reg); }, true, { rex_w(); byte(0x8d); modrm(); })
83
84 binop_x86_inst(Add64, add64, binop_usedef, true, { rex_w(); byte(0x03); modrm(); })
85 binop_x86_inst(Sub64, sub64, binop_usedef, true, { rex_w(); byte(0x2b); modrm(); }) |
Coverage
Diff CoverageDiff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
x86gen.hppLines 420-430 420 X86Inst* mov64_imm64(Reg dst, X86Inst::Imm imm) {
421 return &build(X86Inst::Kind::Mov64Imm64).set_rm(dst).set_imm(imm);
422 }
423
! 424 X86Inst* lea32(Reg dst, X86Inst::Mem src) {
! 425 return &build(X86Inst::Kind::Lea32).set_reg(dst).set_rm(src);
! 426 }
427
428 X86Inst* lea64(Reg dst, X86Inst::Mem src) {
429 return &build(X86Inst::Kind::Lea64).set_reg(dst).set_rm(src);
430 }Lines 776-785 776 }
777
778 void build_add(Reg dst, Value* a, Value* b) {
779 if (dynamic_cast<ShlInst*>(a) || dynamic_cast<MulInst*>(a)) {
! 780 std::swap(a, b);
! 781 }
782 bool use_lea32 = false;
783 X86Inst::Mem mem;
784 if (dynmatch(Const, constant_b, b)) {
785 if (is_sext_imm32(constant_b)) {Lines 804-818 804 } else if (dynmatch(ShlInst, shift, b)) {
805 Type type = a->type();
806 if ((type == Type::Int32 || type == Type::Int64) &&
807 a->is_named() && shift->type() == type && shift->arg(0)->type() == type) {
! 808 if (dynmatch(Const, amount, shift->arg(1))) {
! 809 if (amount->value() >= 1 && amount->value() <= 3) {
! 810 mem = X86Inst::Mem(vreg(a), size_t(1) << amount->value(), vreg(shift->arg(0)), 0);
! 811 use_lea32 = type == Type::Int32;
! 812 }
! 813 }
! 814 }
815 }
816
817 if (mem.is_invalid()) {
818 mem = X86Inst::Mem(Lines 823-831 823 );
824 }
825
826 if (use_lea32) {
! 827 _builder.lea32(dst, mem);
828 } else {
829 _builder.lea64(dst, mem);
830 }
831 }x86insts.inc.hppLines 77-85 77
78 binop_x86_inst(MovZX8To64, movzx8to64, mov_usedef, false, { rex_w(); byte(0x0f); byte(0xb6); modrm(); })
79 binop_x86_inst(MovZX16To64, movzx16to64, mov_usedef, false, { rex_w(); byte(0x0f); byte(0xb7); modrm(); })
80
! 81 x86_inst(Lea32, lea32, { use(rm); def(reg); }, false, { rex_opt(); byte(0x8d); modrm(); })
82 x86_inst(Lea64, lea64, { use(rm); def(reg); }, true, { rex_w(); byte(0x8d); modrm(); })
83
84 binop_x86_inst(Add64, add64, binop_usedef, true, { rex_w(); byte(0x03); modrm(); })
85 binop_x86_inst(Sub64, sub64, binop_usedef, true, { rex_w(); byte(0x2b); modrm(); }) |
Coverage
Diff CoverageDiff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
x86gen.hppLines 776-785 776 }
777
778 void build_add(Reg dst, Type type, Value* a, Value* b) {
779 if (dynamic_cast<ShlInst*>(a) || dynamic_cast<MulInst*>(a)) {
! 780 std::swap(a, b);
! 781 }
782 X86Inst::Mem mem;
783 if (dynmatch(Const, constant_b, b)) {
784 if (is_sext_imm32(constant_b)) {
785 mem = X86Inst::Mem(Lines 803-812 803 } else if (dynmatch(ShlInst, shift, b)) {
804 if (dynmatch(Const, amount, shift->arg(1))) {
805 if (a->is_named() && type_size(type) >= 4 && shift->type() == type &&
806 amount->value() >= 1 && amount->value() <= 3) {
! 807 mem = X86Inst::Mem(vreg(a), size_t(1) << amount->value(), vreg(shift->arg(0)), 0);
! 808 }
809 }
810 }
811
812 if (mem.is_invalid()) { |
Coverage
Diff CoverageDiff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
x86gen.hppLines 777-786 777
778 void build_add(Reg dst, Value* a, Value* b) {
779 Type type = a->type();
780 if (dynamic_cast<ShlInst*>(a) || dynamic_cast<MulInst*>(a)) {
! 781 std::swap(a, b);
! 782 }
783 X86Inst::Mem mem;
784 if (dynmatch(Const, constant_b, b)) {
785 if (is_sext_imm32(constant_b)) {
786 mem = X86Inst::Mem(Lines 803-816 803 }
804 } else if (dynmatch(ShlInst, shift, b)) {
805 if ((type == Type::Int32 || type == Type::Int64) &&
806 a->is_named() && shift->type() == type && shift->arg(0)->type() == type) {
! 807 if (dynmatch(Const, amount, shift->arg(1))) {
! 808 if (amount->value() >= 1 && amount->value() <= 3) {
! 809 mem = X86Inst::Mem(vreg(a), size_t(1) << amount->value(), vreg(shift->arg(0)), 0);
! 810 }
! 811 }
! 812 }
813 }
814
815 if (mem.is_invalid()) {
816 mem = X86Inst::Mem( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.