-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Analysis] Add Scalable field in MemoryLocation.h #65759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,16 +205,16 @@ static bool isShortenableAtTheBeginning(Instruction *I) { | |
return isa<AnyMemSetInst>(I); | ||
} | ||
|
||
static uint64_t getPointerSize(const Value *V, const DataLayout &DL, | ||
const TargetLibraryInfo &TLI, | ||
const Function *F) { | ||
static LocationSize getPointerSize(const Value *V, const DataLayout &DL, | ||
const TargetLibraryInfo &TLI, | ||
const Function *F) { | ||
uint64_t Size; | ||
ObjectSizeOpts Opts; | ||
Opts.NullIsUnknownSize = NullPointerIsDefined(F); | ||
|
||
if (getObjectSize(V, Size, DL, &TLI, Opts)) | ||
return Size; | ||
return MemoryLocation::UnknownSize; | ||
return LocationSize(Size); | ||
return LocationSize(MemoryLocation::UnknownSize); | ||
} | ||
|
||
namespace { | ||
|
@@ -951,9 +951,10 @@ struct DSEState { | |
// case the size/offset of the dead store does not matter. | ||
if (DeadUndObj == KillingUndObj && KillingLocSize.isPrecise() && | ||
isIdentifiedObject(KillingUndObj)) { | ||
uint64_t KillingUndObjSize = getPointerSize(KillingUndObj, DL, TLI, &F); | ||
if (KillingUndObjSize != MemoryLocation::UnknownSize && | ||
KillingUndObjSize == KillingLocSize.getValue()) | ||
LocationSize KillingUndObjSize = | ||
getPointerSize(KillingUndObj, DL, TLI, &F); | ||
if (KillingUndObjSize.hasValue() && | ||
KillingUndObjSize.getValue() == KillingLocSize.getValue()) | ||
return OW_Complete; | ||
} | ||
|
||
|
@@ -976,9 +977,17 @@ struct DSEState { | |
return isMaskedStoreOverwrite(KillingI, DeadI, BatchAA); | ||
} | ||
|
||
const uint64_t KillingSize = KillingLocSize.getValue(); | ||
const uint64_t DeadSize = DeadLoc.Size.getValue(); | ||
const TypeSize KillingSize = KillingLocSize.getValue(); | ||
const TypeSize DeadSize = DeadLoc.Size.getValue(); | ||
// Bail on doing Size comparison which depends on AA for now | ||
// TODO: Remove AnyScalable once Alias Analysis deal with scalable vectors | ||
const bool AnyScalable = | ||
DeadSize.isScalable() || KillingLocSize.isScalable(); | ||
|
||
// TODO: Remove AnyScalable constraint once alias analysis fully support | ||
// scalable quantities | ||
harviniriawan marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+987
to
+988
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This TODO is already above too. |
||
if (AnyScalable) | ||
harviniriawan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return OW_Unknown; | ||
// Query the alias information | ||
AliasResult AAR = BatchAA.alias(KillingLoc, DeadLoc); | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt -S < %s -passes=print-alias-sets 2>&1 | FileCheck %s | ||
|
||
; CHECK-LABEL: Alias sets for function 'sn' | ||
; CHECK: AliasSet[{{.*}}, 1] must alias, Mod Pointers: (ptr %p, unknown after) | ||
define void @sn(ptr %p) {; | ||
store <vscale x 2 x i64> zeroinitializer, ptr %p, align 2 | ||
store i64 0, ptr %p, align 2 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: Alias sets for function 'ns' | ||
; CHECK: AliasSet[{{.*}}, 1] must alias, Mod Pointers: (ptr %p, unknown after) | ||
define void @ns(ptr %p) { | ||
store i64 0, ptr %p, align 2 | ||
store <vscale x 2 x i64> zeroinitializer, ptr %p, align 2 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: Alias sets for function 'ss': | ||
; CHECK: AliasSet[{{.*}}, 1] must alias, Mod Pointers: (ptr %p, LocationSize::precise(vscale x 16)) | ||
define void @ss(ptr %p) { | ||
store <vscale x 2 x i64> zeroinitializer, ptr %p, align 2 | ||
store <vscale x 2 x i64> zeroinitializer, ptr %p, align 2 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: Alias sets for function 'ss2': | ||
; CHECK: AliasSet[{{.*}}, 1] must alias, Mod Pointers: (ptr %p, unknown after) | ||
define void @ss2(ptr %p) { | ||
store <vscale x 2 x i64> zeroinitializer, ptr %p, align 2 | ||
store <vscale x 2 x i64> zeroinitializer, ptr %p, align 2 | ||
store <vscale x 4 x i64> zeroinitializer, ptr %p, align 2 | ||
ret void | ||
} | ||
; CHECK-LABEL: Alias sets for function 'son': | ||
; CHECK: AliasSet[{{.*}}, 2] may alias, Mod Pointers: (ptr %g, LocationSize::precise(vscale x 16)), (ptr %p, LocationSize::precise(8)) | ||
define void @son(ptr %p) { | ||
%g = getelementptr i8, ptr %p, i64 8 | ||
store <vscale x 2 x i64> zeroinitializer, ptr %g, align 2 | ||
store i64 0, ptr %p, align 2 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: Alias sets for function 'sno': | ||
; CHECK: AliasSet[{{.*}}, 2] may alias, Mod Pointers: (ptr %p, LocationSize::precise(vscale x 16)), (ptr %g, LocationSize::precise(8)) | ||
define void @sno(ptr %p) { | ||
%g = getelementptr i8, ptr %p, i64 8 | ||
store <vscale x 2 x i64> zeroinitializer, ptr %p, align 2 | ||
store i64 0, ptr %g, align 2 | ||
ret void | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt -S < %s -passes=gvn | FileCheck %s | ||
|
||
define void @test(i1 %cmp19, ptr %p) { | ||
; CHECK-LABEL: @test( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: br i1 [[CMP19:%.*]], label [[WHILE_BODY_LR_PH:%.*]], label [[FOR_COND_PREHEADER:%.*]] | ||
; CHECK: while.body.lr.ph: | ||
; CHECK-NEXT: [[DOTPRE1:%.*]] = load <vscale x 2 x double>, ptr [[P:%.*]], align 16 | ||
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <vscale x 2 x double> [[DOTPRE1]], i64 0 | ||
; CHECK-NEXT: ret void | ||
; CHECK: for.cond.preheader: | ||
; CHECK-NEXT: [[DOTPRE:%.*]] = load double, ptr [[P]], align 8 | ||
; CHECK-NEXT: [[ADD:%.*]] = fadd double [[DOTPRE]], 0.000000e+00 | ||
; CHECK-NEXT: ret void | ||
; | ||
entry: | ||
br i1 %cmp19, label %while.body.lr.ph, label %for.cond.preheader | ||
|
||
while.body.lr.ph: ; preds = %entry | ||
%.pre1 = load <vscale x 2 x double>, ptr %p, align 16 | ||
%0 = extractelement <vscale x 2 x double> %.pre1, i64 0 | ||
ret void | ||
|
||
for.cond.preheader: ; preds = %entry | ||
%.pre = load double, ptr %p, align 8 | ||
%add = fadd double %.pre, 0.000000e+00 | ||
ret void | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.