-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang] Support fir.pack_array in FIR alias analysis. #131946
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 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
43 changes: 43 additions & 0 deletions
43
flang/test/Analysis/AliasAnalysis/alias-analysis-pack-array.fir
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,43 @@ | ||
// Test alias analysis queries for dummy arguments wired | ||
// through fir.pack_array. | ||
// fir.pack_array is a pass-through operation for FIR alias analysis. | ||
// RUN: fir-opt %s --test-fir-alias-analysis -split-input-file --mlir-disable-threading 2>&1 | FileCheck %s | ||
|
||
// The two pointers referencing two different maybe repacked | ||
// versions of the original dummy arguments do not alias: | ||
// CHECK-DAG: test1_y_repack(1)#0 <-> test1_x_repack(1)#0: NoAlias | ||
// CHECK-DAG: test1_x_orig(1)#0 <-> test1_y_orig(1)#0: NoAlias | ||
|
||
// Repacked dummy does not alias with another original dummy: | ||
// CHECK-DAG: test1_y_repack(1)#0 <-> test1_x_orig(1)#0: NoAlias | ||
// CHECK-DAG: test1_x_repack(1)#0 <-> test1_y_orig(1)#0: NoAlias | ||
|
||
// Repacked dummy may alias with its original: | ||
// CHECK-DAG: test1_x_repack(1)#0 <-> test1_x_orig(1)#0: MayAlias | ||
// CHECK-DAG: test1_y_repack(1)#0 <-> test1_y_orig(1)#0: MayAlias | ||
|
||
// Ideally, these should report MustAlias, but MayAlias | ||
// may work as well: | ||
// CHECK-DAG: test1_y_repack(1)#0 <-> test1_y_repack2(1)#0: MayAlias | ||
// CHECK-DAG: test1_x_repack(1)#0 <-> test1_x_repack2(1)#0: MayAlias | ||
|
||
|
||
func.func @_QFtest1(%arg0: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x"}, %arg1: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "y"}) { | ||
%c1 = arith.constant 1 : index | ||
%0 = fir.dummy_scope : !fir.dscope | ||
%1 = fir.pack_array %arg0 heap whole : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>> | ||
%2:2 = hlfir.declare %1 dummy_scope %0 {uniq_name = "_QFtest1Ex"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>) | ||
%3 = fir.pack_array %arg1 heap whole : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>> | ||
%4:2 = hlfir.declare %3 dummy_scope %0 {uniq_name = "_QFtest1Ey"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>) | ||
%5 = fir.box_addr %4#0 {test.ptr = "test1_y_repack(1)"} : (!fir.box<!fir.array<?xf32>>) -> !fir.ref<f32> | ||
%52 = fir.box_addr %4#0 {test.ptr = "test1_y_repack2(1)"} : (!fir.box<!fir.array<?xf32>>) -> !fir.ref<f32> | ||
%6 = fir.load %5 : !fir.ref<f32> | ||
%7 = fir.box_addr %2#0 {test.ptr = "test1_x_repack(1)"} : (!fir.box<!fir.array<?xf32>>) -> !fir.ref<f32> | ||
%72 = fir.box_addr %2#0 {test.ptr = "test1_x_repack2(1)"} : (!fir.box<!fir.array<?xf32>>) -> !fir.ref<f32> | ||
hlfir.assign %6 to %7 : f32, !fir.ref<f32> | ||
fir.unpack_array %3 to %arg1 heap : !fir.box<!fir.array<?xf32>> | ||
fir.unpack_array %1 to %arg0 heap : !fir.box<!fir.array<?xf32>> | ||
%8 = fir.box_addr %arg0 {test.ptr = "test1_x_orig(1)"} : (!fir.box<!fir.array<?xf32>>) -> !fir.ref<f32> | ||
%9 = fir.box_addr %arg1 {test.ptr = "test1_y_orig(1)"} : (!fir.box<!fir.array<?xf32>>) -> !fir.ref<f32> | ||
return | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jean, as you suggested, I set
approximateSource
forfir.pack_array
. I guess it may be our best bet now.These queries are the ones that look suboptimal, but it should probably not affect performance for the time being.
All, please let me know what you think about this change. If we agree to keep it this way, I will update the doc.