-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[CIR] Upstream handling for __builtin_prefetch #164387
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
+110
−0
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0b07a4a
[CIR] Upstream handling for __builtin_prefetch
kimsh02 645ffaa
Apply feedback
kimsh02 778dee7
Merge branch 'main' into cir-builtin-prefetch
kimsh02 5f40d22
Merge branch 'main' into cir-builtin-prefetch
kimsh02 015ae8e
Merge branch 'main' into cir-builtin-prefetch
kimsh02 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
Some comments aren't visible on the classic Files Changed page.
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
kimsh02 marked this conversation as resolved.
Show resolved
Hide resolved
|
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 @@ | ||
| // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-cir %s -o - | FileCheck %s -check-prefix=CIR | ||
| // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s -check-prefix=LLVM | ||
kimsh02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=OGCG | ||
|
|
||
| void foo(void *a) { | ||
| __builtin_prefetch(a); // rw=0, locality=3 | ||
| __builtin_prefetch(a, 0); // rw=0, locality=3 | ||
| __builtin_prefetch(a, 1); // rw=1, locality=3 | ||
| __builtin_prefetch(a, 1, 1); // rw=1, locality=1 | ||
| } | ||
|
|
||
| // CIR-LABEL: cir.func dso_local @foo( | ||
| // CIR: %[[ALLOCA:.*]] = cir.alloca !cir.ptr<!void> | ||
| // CIR: cir.store %arg0, %[[ALLOCA]] : !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>> | ||
| // CIR: %[[P1:.*]] = cir.load{{.*}} %[[ALLOCA]] : !cir.ptr<!cir.ptr<!void>>, !cir.ptr<!void> | ||
| // CIR: cir.prefetch read locality(3) %[[P1]] : !cir.ptr<!void> | ||
| // CIR: %[[P2:.*]] = cir.load{{.*}} %[[ALLOCA]] : !cir.ptr<!cir.ptr<!void>>, !cir.ptr<!void> | ||
| // CIR: cir.prefetch read locality(3) %[[P2]] : !cir.ptr<!void> | ||
| // CIR: %[[P3:.*]] = cir.load{{.*}} %[[ALLOCA]] : !cir.ptr<!cir.ptr<!void>>, !cir.ptr<!void> | ||
| // CIR: cir.prefetch write locality(3) %[[P3]] : !cir.ptr<!void> | ||
| // CIR: %[[P4:.*]] = cir.load{{.*}} %[[ALLOCA]] : !cir.ptr<!cir.ptr<!void>>, !cir.ptr<!void> | ||
| // CIR: cir.prefetch write locality(1) %[[P4]] : !cir.ptr<!void> | ||
| // CIR: cir.return | ||
|
|
||
| // LLVM-LABEL: define dso_local void @foo( | ||
| // LLVM: [[ALLOCA:%.*]] = alloca ptr, i64 1 | ||
| // LLVM: store ptr {{.*}}, ptr [[ALLOCA]] | ||
| // LLVM: [[LP1:%.*]] = load ptr, ptr [[ALLOCA]] | ||
| // LLVM: call void @llvm.prefetch.p0(ptr [[LP1]], i32 0, i32 3, i32 1) | ||
| // LLVM: [[LP2:%.*]] = load ptr, ptr [[ALLOCA]] | ||
| // LLVM: call void @llvm.prefetch.p0(ptr [[LP2]], i32 0, i32 3, i32 1) | ||
| // LLVM: [[LP3:%.*]] = load ptr, ptr [[ALLOCA]] | ||
| // LLVM: call void @llvm.prefetch.p0(ptr [[LP3]], i32 1, i32 3, i32 1) | ||
| // LLVM: [[LP4:%.*]] = load ptr, ptr [[ALLOCA]] | ||
| // LLVM: call void @llvm.prefetch.p0(ptr [[LP4]], i32 1, i32 1, i32 1) | ||
| // LLVM: ret void | ||
|
|
||
| // OGCG-LABEL: define dso_local void @foo(ptr | ||
| // OGCG: call void @llvm.prefetch.p0(ptr {{.*}}, i32 0, i32 3, i32 1) | ||
| // OGCG: call void @llvm.prefetch.p0(ptr {{.*}}, i32 0, i32 3, i32 1) | ||
| // OGCG: call void @llvm.prefetch.p0(ptr {{.*}}, i32 1, i32 3, i32 1) | ||
| // OGCG: call void @llvm.prefetch.p0(ptr {{.*}}, i32 1, i32 1, i32 1) | ||
| // OGCG: 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.