forked from OSchip/llvm-project
For ISD::RET, if # of operands >= 2, try selection the real data dep. operand
first before the chain. e.g. int X; int foo(int x) { x += X + 37; return x; } If chain operand is selected first, we would generate: movl X, %eax movl 4(%esp), %ecx leal 37(%ecx,%eax), %eax rather than movl $37, %eax addl 4(%esp), %eax addl X, %eax which does not require %ecx. (Due to ADD32rm not matching.) llvm-svn: 24673
This commit is contained in:
parent
cd54254af3
commit
bfd259a2b7
|
@ -356,15 +356,22 @@ SDOperand X86DAGToDAGISel::Select(SDOperand Op) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ISD::RET: {
|
case ISD::RET: {
|
||||||
SDOperand Chain = Select(N->getOperand(0)); // Token chain.
|
SDOperand Chain = N->getOperand(0); // Token chain.
|
||||||
switch (N->getNumOperands()) {
|
unsigned NumOps = N->getNumOperands();
|
||||||
|
|
||||||
|
// Note: A bit of a hack / optimization... Try to delay chain selection
|
||||||
|
// as much as possible. So it's more likely it has already been selected
|
||||||
|
// for a real use.
|
||||||
|
switch (NumOps) {
|
||||||
default:
|
default:
|
||||||
assert(0 && "Unknown return instruction!");
|
assert(0 && "Unknown return instruction!");
|
||||||
case 3:
|
case 3:
|
||||||
|
Chain = Select(Chain);
|
||||||
assert(0 && "Not yet handled return instruction!");
|
assert(0 && "Not yet handled return instruction!");
|
||||||
break;
|
break;
|
||||||
case 2: {
|
case 2: {
|
||||||
SDOperand Val = Select(N->getOperand(1));
|
SDOperand Val = Select(N->getOperand(1));
|
||||||
|
Chain = Select(Chain);
|
||||||
switch (N->getOperand(1).getValueType()) {
|
switch (N->getOperand(1).getValueType()) {
|
||||||
default:
|
default:
|
||||||
assert(0 && "All other types should have been promoted!!");
|
assert(0 && "All other types should have been promoted!!");
|
||||||
|
@ -378,6 +385,7 @@ SDOperand X86DAGToDAGISel::Select(SDOperand Op) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
|
Chain = Select(Chain);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (X86Lowering.getBytesToPopOnReturn() == 0)
|
if (X86Lowering.getBytesToPopOnReturn() == 0)
|
||||||
|
|
Loading…
Reference in New Issue