[llvm-commits] [PATCH] Extend BasicAliasAnalysis to recognize cyclic NoAlias phis in loops

Tobias Grosser tobias at grosser.es
Thu Aug 30 08:26:56 PDT 2012


On 08/30/2012 04:48 PM, Arnold Schwaighofer wrote:
> Ping.
>
> On 8/9/2012 10:54 AM, Arnold Schwaighofer wrote:
>> Hi,
>>
>> BasicAliasAnalysis should recognize phis that have incoming values from
>> outside the loop that are known to not alias and whose other incoming
>> values do not change this fact because they perform congruent operations.
>>
>> Example: We want to prove that ptr_phi and ptr_phi2 do not alias each
>> other.

Hi Arnold,

I have really no idea about the alias analysis, but I was surprised to 
see that you add some kind of loop analysis to the basic alias analysis. 
 From my point of view the scev alias analysis would be the better 
match. Running -scev-aa on your test case still gives:

AliasSet[0x1530080, 3] may alias, Mod/Ref
     Pointers: (i32* %ptr_phi, 4), (i32* %ptr2_phi, 4), (i32* %coeff, 4)

AliasSet[0x1530300, 1] must alias, Mod        forwarding to 0x1530080

Asking myself, why this is the case I looked at the scev values of
%ptr_phi and %ptr2_phi.

%ptr_phi = phi i32* [ %ptr, %entry ], [ %ptr_inc, %while.body ]
   -->  {(4 + %ptr2)<nsw>,+,4}<nw><%while.body>
%ptr2_phi = phi i32* [ %ptr2, %entry ], [ %ptr2_inc, %while.body ]
   -->  {%ptr2,+,4}<nw><%while.body>

Digging a little bit into the debugger, the scev-aa can even figure out 
that the offset of between these two pointers is 4. However, for some 
reason it does not prove that they don't alias. Do you understand why 
the scev-aa can not handle this?

Cheers
Tobi



More information about the llvm-commits mailing list