From: Juergen Ributzka Date: Tue, 25 Mar 2014 18:01:25 +0000 (+0000) Subject: [X86TTI] Make constant base pointers for getElementPtr opaque. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=feaa46379a99a12c1ebc07ebc2ced7e2e906031b;p=oota-llvm.git [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204739 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86TargetTransformInfo.cpp b/lib/Target/X86/X86TargetTransformInfo.cpp index 46a1e16d4f9..80f75cd6b6a 100644 --- a/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/lib/Target/X86/X86TargetTransformInfo.cpp @@ -798,8 +798,9 @@ unsigned X86TTI::getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, switch (Opcode) { default: return TCC_Free; case Instruction::GetElementPtr: - if (Idx != 0) - return TCC_Free; + if (Idx == 0) + return 2 * TCC_Basic; + return TCC_Free; case Instruction::Store: ImmIdx = 0; break;