[llvm-commits] [llvm] r122659 - in /llvm/trunk: lib/Transforms/Scalar/LoopIdiomRecognize.cpp test/Transforms/LoopIdiom/basic.ll
Chris Lattner
sabre at nondot.org
Sat Jan 1 19:42:18 PST 2011
On Jan 1, 2011, at 4:54 PM, Frits van Bommel wrote:
> On Sat, Jan 1, 2011 at 8:39 PM, Chris Lattner <sabre at nondot.org> wrote:
>> +/// mayLoopModRefLocation - Return true if the specified loop might do a load or
>> +/// store to the same location that the specified store could store to, which is
>> +/// a loop-strided access.
>> +static bool mayLoopModRefLocation(StoreInst *SI, Loop *L, AliasAnalysis &AA) {
>> + // Get the location that may be stored across the loop. Since the access is
>> + // strided positively through memory, we say that the modified location starts
>> + // at the pointer and has infinite size.
>> + // TODO: Could improve this for constant trip-count loops.
>> + AliasAnalysis::Location StoreLoc =
>> + AliasAnalysis::Location(SI->getPointerOperand());
>> +
>> + for (Loop::block_iterator BI = L->block_begin(), E = L->block_end(); BI != E;
>> + ++BI)
>> + for (BasicBlock::iterator I = (*BI)->begin(), E = (*BI)->end(); I != E; ++I)
>> + if (AA.getModRefInfo(I, StoreLoc) != AliasAnalysis::NoModRef)
>> + return true;
>
> Wouldn't it be cleaner to add an 'I != SI &&' to the condition here
> instead of temporarily removing SI from the block in before calling
> this?
Yes, I did this because I thought it would be useful for memcpy formation, but I changed my mind. I switched to this approach.
> Of course, checking that extra condition for every instruction in the
> loop is probably less efficient, which I'm guessing is the reason you
> did it this way?
I did it this way because I wanted memcpy formation to take the load *and* store out, but I realize now that it would be a bad idea because I *want* an interference when the store aliases the load. Anyway, please take a look at r122678.
-Chris
More information about the llvm-commits
mailing list