Index: include/llvm/Target/TargetLowering.h =================================================================== --- include/llvm/Target/TargetLowering.h +++ include/llvm/Target/TargetLowering.h @@ -1695,6 +1695,12 @@ return false; } + /// Return true if CodeGenPrepare should sink addresses using GetElementPtr + /// instructions. + virtual bool shouldSinkAddressUsingGEP() const { + return false; + } + //===--------------------------------------------------------------------===// // Runtime Library hooks // Index: lib/CodeGen/CodeGenPrepare.cpp =================================================================== --- lib/CodeGen/CodeGenPrepare.cpp +++ lib/CodeGen/CodeGenPrepare.cpp @@ -3316,7 +3328,7 @@ << *MemoryInst << "\n"); if (SunkAddr->getType() != Addr->getType()) SunkAddr = Builder.CreateBitCast(SunkAddr, Addr->getType()); - } else if (AddrSinkUsingGEPs || + } else if (AddrSinkUsingGEPs || TLI->shouldSinkAddressUsingGEP() || (!AddrSinkUsingGEPs.getNumOccurrences() && TM && TM->getSubtargetImpl(*MemoryInst->getParent()->getParent()) ->useAA())) {