Skip to content

Commit 2b37257

Browse files
committed
[BasicAA] Don't track visited blocks for phi-phi alias query
We only need the VisitedPhiBBs to disambiguate comparisons of values from two different loop iterations. If we're comparing two phis from the same basic block in lock-step, the compared values will always be on the same iteration. While this also increases precision, this is mainly intended to clarify the scope of VisitedPhiBBs.
1 parent 57cdc52 commit 2b37257

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

llvm/lib/Analysis/BasicAliasAnalysis.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,10 +1535,6 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
15351535
LocationSize V2Size,
15361536
const AAMDNodes &V2AAInfo,
15371537
const Value *UnderV2, AAQueryInfo &AAQI) {
1538-
// Track phi nodes we have visited. We use this information when we determine
1539-
// value equivalence.
1540-
VisitedPhiBBs.insert(PN->getParent());
1541-
15421538
// If the values are PHIs in the same block, we can do a more precise
15431539
// as well as efficient check: just check for aliases between the values
15441540
// on corresponding edges.
@@ -1655,6 +1651,11 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
16551651
if (isRecursive)
16561652
PNSize = LocationSize::unknown();
16571653

1654+
// In the recursive alias queries below, we may compare values from two
1655+
// different loop iterations. Keep track of visited phi blocks, which will
1656+
// be used when determining value equivalence.
1657+
VisitedPhiBBs.insert(PN->getParent());
1658+
16581659
AliasResult Alias = aliasCheck(V2, V2Size, V2AAInfo, V1Srcs[0], PNSize,
16591660
PNAAInfo, AAQI, UnderV2);
16601661

llvm/test/Analysis/BasicAA/phi-aa.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ exit:
136136
}
137137

138138
; CHECK-LABEL: phi_and_phi_cycle
139-
; CHECK: MayAlias: i32* %p1, i32* %p2
139+
; CHECK: NoAlias: i32* %p1, i32* %p2
140140
define void @phi_and_phi_cycle(i32* noalias %x, i32* noalias %y) {
141141
entry:
142142
br label %loop

0 commit comments

Comments
 (0)