forked from OSchip/llvm-project
[X86TTI] Make constant base pointers for getElementPtr opaque.
If getElementPtr uses a constant as base pointer, then make the constant opaque. This prevents constant folding it with the offset. The offset can usually be encoded in the load/store instruction itself and the base address doesn't have to be rematerialized several times. llvm-svn: 204739
This commit is contained in:
parent
5eef98cf7a
commit
631c4914b2
|
@ -798,8 +798,9 @@ unsigned X86TTI::getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
|
||||||
switch (Opcode) {
|
switch (Opcode) {
|
||||||
default: return TCC_Free;
|
default: return TCC_Free;
|
||||||
case Instruction::GetElementPtr:
|
case Instruction::GetElementPtr:
|
||||||
if (Idx != 0)
|
if (Idx == 0)
|
||||||
return TCC_Free;
|
return 2 * TCC_Basic;
|
||||||
|
return TCC_Free;
|
||||||
case Instruction::Store:
|
case Instruction::Store:
|
||||||
ImmIdx = 0;
|
ImmIdx = 0;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue