[llvm-commits] [llvm] r122678 - in /llvm/trunk: lib/Transforms/Scalar/LoopIdiomRecognize.cpp test/Transforms/LoopIdiom/basic.ll

Chris Lattner sabre at nondot.org
Sun Jan 2 10:35:44 PST 2011


On Jan 2, 2011, at 2:08 AM, Frits van Bommel wrote:
> On Sun, Jan 2, 2011 at 4:37 AM, Chris Lattner <sabre at nondot.org> wrote:
>> +/// processLoopStoreOfLoopLoad - We see a strided store whose value is a
>> +/// same-strided load.
>> +bool LoopIdiomRecognize::
>> +processLoopStoreOfLoopLoad(StoreInst *SI, unsigned StoreSize,
>> +                           const SCEVAddRecExpr *StoreEv,
>> +                           const SCEVAddRecExpr *LoadEv,
>> +                           const SCEV *BECount) {
>> +  LoadInst *LI = cast<LoadInst>(SI->getValueOperand());
>> +
>> +  // Okay, we have a strided store "p[i]" of a loaded value.  We can turn
>> +  // this into a memcmp in the loop preheader now if we want.  However, this
> 
> s/memcmp/memcpy/

Thanks, fixed in r122701.

>> +  // would be unsafe to do if there is anything else in the loop that may read
>> +  // or write to the aliased location (including the load feeding the stores).
>> +  // Check for an alias.
> 
> TODO: If *only* the load feeding the stores aliases them, turn it into
> memmove instead :). (unless the load has other uses)

Yep, that occurred to me.  This is somewhat tricky to do though, I don't plan to do this in the short term.

-Chris



More information about the llvm-commits mailing list