mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +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:
parent
4ba9cd53ba
commit
224ec39cab
@ -457,23 +457,19 @@ bool X86DAGToDAGISel::SelectLEAAddr(SDOperand N, SDOperand &Base,
|
||||
SDOperand &Index, SDOperand &Disp) {
|
||||
X86ISelAddressMode AM;
|
||||
if (!MatchAddress(N, AM)) {
|
||||
bool SelectBase = false;
|
||||
bool SelectIndex = false;
|
||||
bool Check = false;
|
||||
if (AM.BaseType == X86ISelAddressMode::RegBase) {
|
||||
if (AM.Base.Reg.Val) {
|
||||
Check = true;
|
||||
SelectBase = true;
|
||||
} else {
|
||||
if (AM.Base.Reg.Val)
|
||||
Check = true;
|
||||
else
|
||||
AM.Base.Reg = CurDAG->getRegister(0, MVT::i32);
|
||||
}
|
||||
}
|
||||
|
||||
if (AM.IndexReg.Val) {
|
||||
if (AM.IndexReg.Val)
|
||||
SelectIndex = true;
|
||||
} else {
|
||||
else
|
||||
AM.IndexReg = CurDAG->getRegister(0, MVT::i32);
|
||||
}
|
||||
|
||||
if (Check) {
|
||||
unsigned Complexity = 0;
|
||||
@ -485,6 +481,13 @@ bool X86DAGToDAGISel::SelectLEAAddr(SDOperand N, SDOperand &Base,
|
||||
Complexity++;
|
||||
else if (AM.Disp > 1)
|
||||
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)
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user