Add comments and test case for [X86TTI] Make constant base pointers for GetElementPtr opaque (r204739).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205468 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Juergen Ributzka
2014-04-02 21:45:36 +00:00
parent 6d4e5ab349
commit 172e0ca8c5
2 changed files with 27 additions and 0 deletions
@@ -915,6 +915,9 @@ unsigned X86TTI::getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
switch (Opcode) {
default: return TCC_Free;
case Instruction::GetElementPtr:
// Always hoist the base address of a GetElementPtr. This prevents the
// creation of new constants for every base constant that gets constant
// folded with the offset.
if (Idx == 0)
return 2 * TCC_Basic;
return TCC_Free;