- Fixes a bug when calculating the offset in GetLinearExpression. The code previously used zext to extend the offset, so negative offsets were converted to large positive ones.
- Enhance aliasGEP to deduce that, if the difference between two GEP allocations is positive and all the variables that govern the offset are also positive (i.e. the offset is strictly after the higher base pointer), then allocations that fit in the gap between the two base pointers are NoAlias.
Details
- Reviewers
hfinkel
Diff Detail
Event Timeline
lib/Analysis/BasicAliasAnalysis.cpp | ||
---|---|---|
258 | Start sentence with a capital w (similar with other comments below). | |
1067 | To note a possible follow-up, we might also be able to determine this by using ComputeSignBit from ValueTracking.h | |
1084 | Add a space in between the if and the ( | |
1231 | I think you can remove the ("don't know") next to MayAlias. More importantly, please also explain in the comment what the loop below actually checks and why that ensures the condition you explain above. Also, an example of this would be helpful. | |
1239 | Space after the if. |
@hfinkel Thanks for the review - I've updated the patch to fix this issues you mentioned.
lib/Analysis/BasicAliasAnalysis.cpp | ||
---|---|---|
1242 | As you've written the example, %phi and %idx don't alias, because %idx == %phi+1. If you take out the add and store the original value (or don't update*%somewhere at all), then they will alias. | |
1247 | When you see "we can see that", you mean that without this check we'd return NoAlias, right? That does not seem right. Without this patch (current trunk), if I take this function: define void @test1(i64* noalias %somewhere, i32* noalias %memory) { entry: br label %for.body for.body: %phi = phi i32* [%idx, %for.body], [null, %entry] %i = load i64* %somewhere %idx = getelementptr inbounds i32* %memory, i64 %i %i.plus1 = add nsw nuw i64 %i, 1 store i64 %i.plus1, i64* %somewhere br label %for.body } and run it through: opt < -basicaa -aa-eval -print-all-alias-modref-info -disable-output I get: Function: test1: 4 pointers, 0 call sites NoAlias: i32* %memory, i64* %somewhere NoAlias: i32* %phi, i64* %somewhere MayAlias: i32* %memory, i32* %phi NoAlias: i32* %idx, i64* %somewhere PartialAlias: i32* %idx, i32* %memory MayAlias: i32* %idx, i32* %phi which already gives "MayAlias: i32* %idx, i32* %phi". In short, I'm still not entirely sure I understand the problem you're trying to fix here. | |
1256 | What do you mean by "tightened" here? | |
1259 | Space after the if. |
@hfinkel - thanks for your patience, I understand it now. I was basically trying to re-invent isValueEqualInPotentialCycles, so I've cut that bit completely from the patch. I've also added the ComputeSignBit check you suggested, and a test using lshr to demonstrate that it works.
Start sentence with a capital w (similar with other comments below).