-
Notifications
You must be signed in to change notification settings - Fork 14.3k
InferAddressSpaces: Handle llvm.is.constant #102010
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
arsenm
merged 1 commit into
main
from
users/arsenm/infer-address-spaces-handle-is-constant
Aug 5, 2024
Merged
Changes from all commits
Commits
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
56 changes: 56 additions & 0 deletions
56
llvm/test/Transforms/InferAddressSpaces/AMDGPU/is.constant.ll
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,56 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=infer-address-spaces %s | FileCheck %s | ||
|
||
define i1 @is_constant_global_to_flat(ptr addrspace(1) %ptr) { | ||
; CHECK-LABEL: define i1 @is_constant_global_to_flat( | ||
; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]]) { | ||
; CHECK-NEXT: [[RET:%.*]] = call i1 @llvm.is.constant.p1(ptr addrspace(1) [[PTR]]) | ||
; CHECK-NEXT: ret i1 [[RET]] | ||
; | ||
%cast = addrspacecast ptr addrspace(1) %ptr to ptr | ||
%ret = call i1 @llvm.is.constant.p0(ptr %cast) | ||
ret i1 %ret | ||
} | ||
|
||
define i1 @is_constant_local_to_flat(ptr addrspace(3) %ptr) { | ||
; CHECK-LABEL: define i1 @is_constant_local_to_flat( | ||
; CHECK-SAME: ptr addrspace(3) [[PTR:%.*]]) { | ||
; CHECK-NEXT: [[RET:%.*]] = call i1 @llvm.is.constant.p3(ptr addrspace(3) [[PTR]]) | ||
; CHECK-NEXT: ret i1 [[RET]] | ||
; | ||
%cast = addrspacecast ptr addrspace(3) %ptr to ptr | ||
%ret = call i1 @llvm.is.constant.p0(ptr %cast) | ||
ret i1 %ret | ||
} | ||
|
||
define i1 @is_constant_private_to_flat(ptr addrspace(5) %ptr) { | ||
; CHECK-LABEL: define i1 @is_constant_private_to_flat( | ||
; CHECK-SAME: ptr addrspace(5) [[PTR:%.*]]) { | ||
; CHECK-NEXT: [[RET:%.*]] = call i1 @llvm.is.constant.p5(ptr addrspace(5) [[PTR]]) | ||
; CHECK-NEXT: ret i1 [[RET]] | ||
; | ||
%cast = addrspacecast ptr addrspace(5) %ptr to ptr | ||
%ret = call i1 @llvm.is.constant.p0(ptr %cast) | ||
ret i1 %ret | ||
} | ||
|
||
define i1 @is_constant_private_to_flat_v2(<2 x ptr addrspace(5)> %ptr) { | ||
; CHECK-LABEL: define i1 @is_constant_private_to_flat_v2( | ||
; CHECK-SAME: <2 x ptr addrspace(5)> [[PTR:%.*]]) { | ||
; CHECK-NEXT: [[RET:%.*]] = call i1 @llvm.is.constant.v2p5(<2 x ptr addrspace(5)> [[PTR]]) | ||
; CHECK-NEXT: ret i1 [[RET]] | ||
; | ||
%cast = addrspacecast <2 x ptr addrspace(5)> %ptr to <2 x ptr> | ||
%ret = call i1 @llvm.is.constant.v2p0(<2 x ptr> %cast) | ||
ret i1 %ret | ||
} | ||
|
||
define i1 @is_constant_i32(i32 %val) { | ||
; CHECK-LABEL: define i1 @is_constant_i32( | ||
; CHECK-SAME: i32 [[VAL:%.*]]) { | ||
; CHECK-NEXT: [[RET:%.*]] = call i1 @llvm.is.constant.i32(i32 [[VAL]]) | ||
; CHECK-NEXT: ret i1 [[RET]] | ||
; | ||
%ret = call i1 @llvm.is.constant.i32(i32 %val) | ||
ret i1 %ret | ||
} |
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.
unnecessary braces?
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.
Multiple lines
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.
multiple lines is not listed as an excuse in the coding style
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.
"However, braces should be used in cases where the omission of braces harm the readability and maintainability of the code."
and in my judgment this covers any situation with multiple lines
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.
How could it hurt readability?
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.
Because unlike a compiler I read by lines, and not statements.
The length of that section of the style guide is absurd. It should never be wrong to include braces. That's a lot simpler than parsing out whatever that is
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.
Having to deal with google style that demands braces everywhere, and LLVM which does not want them, my personal choice is "whatever the style guide says". It may not always be a perfect choice, but it's not worth anyone's time to argue over specific instances, where the right choice is ambiguous or is a matter of personal preference. I wish we could delegate braces/no-braces decisions to clang-format, too, but I don't think it currently handles that.
I'd stick with the style guide defaults and either have the braces removed, or a comment added to the body. Perhaps, making the function name shorter, and avoiding line-wrapping would address your readability concerns about braces/no-braces here, too.
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.
This rule is so open ended it's useless. If clang-format doesn't do this, it's not a rule. I'm not wasting more CI cycles to touch this