@@ -1173,7 +1173,7 @@ AliasResult BasicAAResult::aliasGEP(
1173
1173
// VScale Alias Analysis - Given one scalable offset between accesses and a
1174
1174
// scalable typesize, we can divide each side by vscale, treating both values
1175
1175
// as a constant. We prove that Offset/vscale >= TypeSize/vscale.
1176
- if (DecompGEP1.VarIndices .size () == 1 && DecompGEP1. VarIndices [ 0 ]. IsNSW &&
1176
+ if (DecompGEP1.VarIndices .size () == 1 &&
1177
1177
DecompGEP1.VarIndices [0 ].Val .TruncBits == 0 &&
1178
1178
DecompGEP1.Offset .isZero () &&
1179
1179
PatternMatch::match (DecompGEP1.VarIndices [0 ].Val .V ,
@@ -1183,12 +1183,22 @@ AliasResult BasicAAResult::aliasGEP(
1183
1183
ScalableVar.IsNegated ? -ScalableVar.Scale : ScalableVar.Scale ;
1184
1184
LocationSize VLeftSize = Scale.isNegative () ? V1Size : V2Size;
1185
1185
1186
- // Note that we do not check that the typesize is scalable, as vscale >= 1
1187
- // so noalias still holds so long as the dependency distance is at least as
1188
- // big as the typesize.
1189
- if (VLeftSize.hasValue () &&
1190
- Scale.uge (VLeftSize.getValue ().getKnownMinValue ()))
1191
- return AliasResult::NoAlias;
1186
+ // Check if the offset is known to not overflow, if it does then attempt to
1187
+ // prove it with the known values of vscale_range.
1188
+ bool Overflows = !DecompGEP1.VarIndices [0 ].IsNSW ;
1189
+ if (Overflows) {
1190
+ ConstantRange CR = getVScaleRange (&F, Scale.getBitWidth ());
1191
+ (void )CR.getSignedMax ().smul_ov (Scale, Overflows);
1192
+ }
1193
+
1194
+ if (!Overflows) {
1195
+ // Note that we do not check that the typesize is scalable, as vscale >= 1
1196
+ // so noalias still holds so long as the dependency distance is at least
1197
+ // as big as the typesize.
1198
+ if (VLeftSize.hasValue () &&
1199
+ Scale.uge (VLeftSize.getValue ().getKnownMinValue ()))
1200
+ return AliasResult::NoAlias;
1201
+ }
1192
1202
}
1193
1203
1194
1204
// Bail on analysing scalable LocationSize
0 commit comments