-
Couldn't load subscription status.
- Fork 794
[SYCLLowerIR][GlobalOffset] Fix collection order of load's defs #20428
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
5 commits
Select commit
Hold shift + click to select a range
cc75265
[SYCLLowerIR][GlobalOffset] Fix collection order of load's defs
wenju-he e4167e6
update comment
wenju-he e986c0b
don't add call inst to PtrUses
wenju-he 030a41e
remove .second
wenju-he 88ffae7
update per review comment
wenju-he 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| ; RUN: opt -bugpoint-enable-legacy-pm -globaloffset %s -S -o - | FileCheck %s | ||
|
|
||
| ; Check that phi is correctly handled in load's defs collection. | ||
|
|
||
| target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9" | ||
| target triple = "amdgcn-amd-amdhsa" | ||
|
|
||
| define i64 @test_phi(i32 %x) { | ||
| ; CHECK-LABEL: define i64 @test_phi( | ||
| ; CHECK-SAME: i32 [[X:%.*]]) { | ||
| ; CHECK-NEXT: [[ENTRY:.*:]] | ||
| ; CHECK-NEXT: switch i32 [[X]], label %[[B5:.*]] [ | ||
| ; CHECK-NEXT: i32 0, label %[[B1:.*]] | ||
| ; CHECK-NEXT: i32 1, label %[[B2:.*]] | ||
| ; CHECK-NEXT: i32 2, label %[[B3:.*]] | ||
| ; CHECK-NEXT: ] | ||
| ; CHECK: [[B1]]: | ||
| ; CHECK-NEXT: br label %[[B4:.*]] | ||
| ; CHECK: [[B2]]: | ||
| ; CHECK-NEXT: br label %[[B4]] | ||
| ; CHECK: [[B3]]: | ||
| ; CHECK-NEXT: br label %[[B4]] | ||
| ; CHECK: [[B4]]: | ||
| ; CHECK-NEXT: [[EXT1:%.*]] = zext i32 0 to i64 | ||
| ; CHECK-NEXT: [[EXT2:%.*]] = zext i32 0 to i64 | ||
| ; CHECK-NEXT: [[RES:%.*]] = add nuw nsw i64 [[EXT1]], [[EXT2]] | ||
| ; CHECK-NEXT: ret i64 [[RES]] | ||
| ; CHECK: [[B5]]: | ||
| ; CHECK-NEXT: unreachable | ||
| ; | ||
| entry: | ||
| switch i32 %x, label %b5 [ | ||
| i32 0, label %b1 | ||
| i32 1, label %b2 | ||
| i32 2, label %b3 | ||
| ] | ||
|
|
||
| b1: ; preds = %entry | ||
| %offset0 = tail call ptr addrspace(5) @llvm.amdgcn.implicit.offset() | ||
| br label %b4 | ||
|
|
||
| b2: ; preds = %entry | ||
| %offset1 = tail call ptr addrspace(5) @llvm.amdgcn.implicit.offset() | ||
| %gep1 = getelementptr inbounds nuw i8, ptr addrspace(5) %offset1, i32 4 | ||
| br label %b4 | ||
|
|
||
| b3: ; preds = %entry | ||
| %offset2 = tail call ptr addrspace(5) @llvm.amdgcn.implicit.offset() | ||
| %gep2 = getelementptr inbounds nuw i8, ptr addrspace(5) %offset2, i32 8 | ||
| br label %b4 | ||
|
|
||
| b4: ; preds = %b3, %b2, %b1 | ||
| %p = phi ptr addrspace(5) [ %offset0, %b1 ], [ %gep1, %b2 ], [ %gep2, %b3 ] | ||
| %load1 = load i32, ptr addrspace(5) %p, align 4 | ||
| %load2 = load i32, ptr addrspace(5) %p, align 4 | ||
| %ext1 = zext i32 %load1 to i64 | ||
| %ext2 = zext i32 %load2 to i64 | ||
| %res = add nuw nsw i64 %ext1, %ext2 | ||
| ret i64 %res | ||
|
|
||
| b5: ; preds = %entry | ||
| unreachable | ||
| } | ||
|
|
||
| ; CHECK-LABEL: define i64 @test_phi_with_offset( | ||
| ; CHECK-SAME: i32 [[X:%.*]], ptr addrspace(5) [[PTR:%.*]]) { | ||
| ; CHECK-NEXT: [[ENTRY:.*:]] | ||
| ; CHECK-NEXT: switch i32 [[X]], label %[[B5:.*]] [ | ||
| ; CHECK-NEXT: i32 0, label %[[B1:.*]] | ||
| ; CHECK-NEXT: i32 1, label %[[B2:.*]] | ||
| ; CHECK-NEXT: i32 2, label %[[B3:.*]] | ||
| ; CHECK-NEXT: ] | ||
| ; CHECK: [[B1]]: | ||
| ; CHECK-NEXT: br label %[[B4:.*]] | ||
| ; CHECK: [[B2]]: | ||
| ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds nuw i8, ptr addrspace(5) [[PTR]], i32 4 | ||
| ; CHECK-NEXT: br label %[[B4]] | ||
| ; CHECK: [[B3]]: | ||
| ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds nuw i8, ptr addrspace(5) [[PTR]], i32 8 | ||
| ; CHECK-NEXT: br label %[[B4]] | ||
| ; CHECK: [[B4]]: | ||
| ; CHECK-NEXT: [[P:%.*]] = phi ptr addrspace(5) [ [[PTR]], %[[B1]] ], [ [[GEP1]], %[[B2]] ], [ [[GEP2]], %[[B3]] ] | ||
| ; CHECK-NEXT: [[LOAD1:%.*]] = load i32, ptr addrspace(5) [[P]], align 4 | ||
| ; CHECK-NEXT: [[LOAD2:%.*]] = load i32, ptr addrspace(5) [[P]], align 4 | ||
| ; CHECK-NEXT: [[EXT1:%.*]] = zext i32 [[LOAD1]] to i64 | ||
| ; CHECK-NEXT: [[EXT2:%.*]] = zext i32 [[LOAD2]] to i64 | ||
| ; CHECK-NEXT: [[RES:%.*]] = add nuw nsw i64 [[EXT1]], [[EXT2]] | ||
| ; CHECK-NEXT: ret i64 [[RES]] | ||
| ; CHECK: [[B5]]: | ||
| ; CHECK-NEXT: unreachable | ||
|
|
||
| declare ptr addrspace(5) @llvm.amdgcn.implicit.offset() | ||
|
|
||
| !llvm.module.flags = !{!0} | ||
|
|
||
| !0 = !{i32 1, !"sycl-device", i32 1} | ||
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,34 @@ | ||
| ; RUN: opt -bugpoint-enable-legacy-pm -globaloffset %s -S -o - | FileCheck %s | ||
|
|
||
| target datalayout = "e-p6:32:32-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64" | ||
| target triple = "nvptx64-nvidia-cuda" | ||
|
|
||
| declare ptr @llvm.nvvm.implicit.offset() | ||
|
|
||
| define i32 @test_two_loads() { | ||
| ; CHECK-LABEL: define i32 @test_two_loads() { | ||
| ; CHECK-NEXT: [[ENTRY:.*:]] | ||
| ; CHECK-NEXT: [[RES:%.*]] = add i32 0, 0 | ||
| ; CHECK-NEXT: ret i32 [[RES]] | ||
| ; | ||
| entry: | ||
| %offset = tail call ptr @llvm.nvvm.implicit.offset() | ||
| %gep = getelementptr inbounds nuw i8, ptr %offset, i64 4 | ||
| %load1 = load i32, ptr %gep, align 4 | ||
| %load2 = load i32, ptr %offset, align 4 | ||
| %res = add i32 %load1, %load2 | ||
| ret i32 %res | ||
| } | ||
|
|
||
| ; CHECK-LABEL: define i32 @test_two_loads_with_offset( | ||
| ; CHECK-SAME: ptr [[PTR:%.*]]) { | ||
| ; CHECK-NEXT: [[ENTRY:.*:]] | ||
| ; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds nuw i8, ptr [[PTR]], i64 4 | ||
| ; CHECK-NEXT: [[LOAD1:%.*]] = load i32, ptr [[GEP]], align 4 | ||
| ; CHECK-NEXT: [[LOAD2:%.*]] = load i32, ptr [[PTR]], align 4 | ||
| ; CHECK-NEXT: [[RES:%.*]] = add i32 [[LOAD1]], [[LOAD2]] | ||
| ; CHECK-NEXT: ret i32 [[RES]] | ||
|
|
||
| !llvm.module.flags = !{!0} | ||
|
|
||
| !0 = !{i32 1, !"sycl-device", i32 1} |
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.
nit:
would it make sense to add test, where result of load is used? What would happen with those uses?
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.
done, updated the test to have detailed check, thanks