mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 20:29:53 +00:00
A addressing mode folding enhancement:
Fold c2 in (x << c1) | c2 where (c2 < c1) e.g. int test(int x) { return (x << 3) + 7; } This can be codegen'd as: leal 7(,%eax,8), %eax git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28550 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dc7dd9719d
commit
e6ad27e917
@ -392,6 +392,30 @@ bool X86DAGToDAGISel::MatchAddress(SDOperand N, X86ISelAddressMode &AM,
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ISD::OR: {
|
||||
if (!Available) {
|
||||
X86ISelAddressMode Backup = AM;
|
||||
// Look for (x << c1) | c2 where (c2 < c1)
|
||||
ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N.Val->getOperand(0));
|
||||
if (CN && !MatchAddress(N.Val->getOperand(1), AM, false)) {
|
||||
if (AM.GV == NULL && AM.Disp == 0 && CN->getValue() < AM.Scale) {
|
||||
AM.Disp = CN->getValue();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
AM = Backup;
|
||||
CN = dyn_cast<ConstantSDNode>(N.Val->getOperand(1));
|
||||
if (CN && !MatchAddress(N.Val->getOperand(0), AM, false)) {
|
||||
if (AM.GV == NULL && AM.Disp == 0 && CN->getValue() < AM.Scale) {
|
||||
AM.Disp = CN->getValue();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
AM = Backup;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Is the base register already occupied?
|
||||
|
@ -133,7 +133,7 @@ def brtarget : Operand<OtherVT>;
|
||||
// Define X86 specific addressing mode.
|
||||
def addr : ComplexPattern<iPTR, 4, "SelectAddr", []>;
|
||||
def leaaddr : ComplexPattern<iPTR, 4, "SelectLEAAddr",
|
||||
[add, mul, shl, frameindex]>;
|
||||
[add, mul, shl, or, frameindex]>;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// X86 Instruction Format Definitions.
|
||||
|
Loading…
Reference in New Issue
Block a user