Skip to content

Commit ea4cc20

Browse files
authored
[BasicAA] Remove NSW flags when merging scales (#69122)
When merging scales of `LinearExpression` that have common index variables, we cannot guarantee the NSW flag still applies to the merged expression. Fixes #69096.
1 parent 96196e2 commit ea4cc20

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

llvm/lib/Analysis/BasicAliasAnalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ BasicAAResult::DecomposeGEPExpression(const Value *V, const DataLayout &DL,
662662
if (Decomposed.VarIndices[i].Val.V == LE.Val.V &&
663663
Decomposed.VarIndices[i].Val.hasSameCastsAs(LE.Val)) {
664664
Scale += Decomposed.VarIndices[i].Scale;
665+
LE.IsNSW = false; // We cannot guarantee nsw for the merge.
665666
Decomposed.VarIndices.erase(Decomposed.VarIndices.begin() + i);
666667
break;
667668
}

llvm/test/Analysis/BasicAA/pr69096.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
target datalayout = "p:64:64:64"
44

55
; CHECK-LABEL: Function: pr69096
6-
; FIXME: This should be MayAlias. %p == %scevgep.i when %a == -1.
7-
; CHECK: NoAlias: i8* %p, i16* %scevgep.i
6+
; %p == %scevgep.i when %a == -1.
7+
; CHECK: MayAlias: i8* %p, i16* %scevgep.i
88

99
define i32 @pr69096(i16 %a, ptr %p) {
1010
entry:

0 commit comments

Comments
 (0)