mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
X86 codegen tweak to use lea in another case:
Suppose base == %eax and it has multiple uses, then instead of movl %eax, %ecx addl $8, %ecx use leal 8(%eax), %ecx. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26323 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -457,23 +457,19 @@ bool X86DAGToDAGISel::SelectLEAAddr(SDOperand N, SDOperand &Base,
|
|||||||
SDOperand &Index, SDOperand &Disp) {
|
SDOperand &Index, SDOperand &Disp) {
|
||||||
X86ISelAddressMode AM;
|
X86ISelAddressMode AM;
|
||||||
if (!MatchAddress(N, AM)) {
|
if (!MatchAddress(N, AM)) {
|
||||||
bool SelectBase = false;
|
|
||||||
bool SelectIndex = false;
|
bool SelectIndex = false;
|
||||||
bool Check = false;
|
bool Check = false;
|
||||||
if (AM.BaseType == X86ISelAddressMode::RegBase) {
|
if (AM.BaseType == X86ISelAddressMode::RegBase) {
|
||||||
if (AM.Base.Reg.Val) {
|
if (AM.Base.Reg.Val)
|
||||||
Check = true;
|
Check = true;
|
||||||
SelectBase = true;
|
else
|
||||||
} else {
|
|
||||||
AM.Base.Reg = CurDAG->getRegister(0, MVT::i32);
|
AM.Base.Reg = CurDAG->getRegister(0, MVT::i32);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AM.IndexReg.Val) {
|
if (AM.IndexReg.Val)
|
||||||
SelectIndex = true;
|
SelectIndex = true;
|
||||||
} else {
|
else
|
||||||
AM.IndexReg = CurDAG->getRegister(0, MVT::i32);
|
AM.IndexReg = CurDAG->getRegister(0, MVT::i32);
|
||||||
}
|
|
||||||
|
|
||||||
if (Check) {
|
if (Check) {
|
||||||
unsigned Complexity = 0;
|
unsigned Complexity = 0;
|
||||||
@@ -485,6 +481,13 @@ bool X86DAGToDAGISel::SelectLEAAddr(SDOperand N, SDOperand &Base,
|
|||||||
Complexity++;
|
Complexity++;
|
||||||
else if (AM.Disp > 1)
|
else if (AM.Disp > 1)
|
||||||
Complexity++;
|
Complexity++;
|
||||||
|
// Suppose base == %eax and it has multiple uses, then instead of
|
||||||
|
// movl %eax, %ecx
|
||||||
|
// addl $8, %ecx
|
||||||
|
// use
|
||||||
|
// leal 8(%eax), %ecx.
|
||||||
|
if (AM.Base.Reg.Val->use_size() > 1)
|
||||||
|
Complexity++;
|
||||||
if (Complexity <= 1)
|
if (Complexity <= 1)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user