-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[SROA] Prevent load atomic vector from being generated #112432
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
Open
jofrn
wants to merge
10
commits into
llvm:main
Choose a base branch
from
jofrn:atomicvec-sroa
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cb05b56
[SROA] Prevent load atomic vector from being generated
jofrn 0c61505
Autogenerate assertions
jofrn 083346d
Add i32,ptr tests and rename variables
jofrn cf47505
memcpy size must be >=8 to generate load atomic <1 x ptr>
jofrn ef4fe92
Use isValidAtomicTy
jofrn bdebaa8
Add AtomicOrdering to isValidAtomicTy interface
jofrn d68d923
Updated basictest.ll for checking getTypeSizeInBits
jofrn 1c1aae7
Revert basictest.ll changes and DL check
jofrn 67e0560
Add <2 x i32> test. Add DL as optional to isValidAtomicTy
jofrn e2e58ee
Added nonbyte test. Removed interface to isValidAtomicTy.
jofrn 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2853,6 +2853,11 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> { | |||||
|
||||||
bool visitLoadInst(LoadInst &LI) { | ||||||
LLVM_DEBUG(dbgs() << " original: " << LI << "\n"); | ||||||
|
||||||
// load atomic vector would be generated, which is illegal | ||||||
|
// load atomic vector would be generated, which is illegal | |
// Load atomic vector would be generated, which is illegal. |
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,53 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt < %s -passes='sroa' -S | FileCheck %s | ||
|
||
define float @atomic_vector() { | ||
; CHECK-LABEL: define float @atomic_vector() { | ||
; CHECK-NEXT: [[TMP1:%.*]] = alloca <1 x float>, align 4 | ||
; CHECK-NEXT: store <1 x float> undef, ptr [[TMP1]], align 4 | ||
; CHECK-NEXT: [[TMP2:%.*]] = load atomic volatile float, ptr [[TMP1]] acquire, align 4 | ||
; CHECK-NEXT: ret float [[TMP2]] | ||
; | ||
%src = alloca <1 x float> | ||
%val = alloca <1 x float> | ||
%direct = alloca ptr | ||
call void @llvm.memcpy.p0.p0.i64(ptr %val, ptr %src, i64 4, i1 false) | ||
store ptr %val, ptr %direct | ||
%indirect = load ptr, ptr %direct | ||
%ret = load atomic volatile float, ptr %indirect acquire, align 4 | ||
ret float %ret | ||
} | ||
|
||
define i32 @atomic_vector_int() { | ||
; CHECK-LABEL: define i32 @atomic_vector_int() { | ||
; CHECK-NEXT: [[VAL:%.*]] = alloca <1 x i32>, align 4 | ||
; CHECK-NEXT: store <1 x i32> undef, ptr [[VAL]], align 4 | ||
; CHECK-NEXT: [[RET:%.*]] = load atomic volatile i32, ptr [[VAL]] acquire, align 4 | ||
; CHECK-NEXT: ret i32 [[RET]] | ||
; | ||
%src = alloca <1 x i32> | ||
%val = alloca <1 x i32> | ||
%direct = alloca ptr | ||
call void @llvm.memcpy.p0.p0.i64(ptr %val, ptr %src, i64 4, i1 false) | ||
store ptr %val, ptr %direct | ||
%indirect = load ptr, ptr %direct | ||
%ret = load atomic volatile i32, ptr %indirect acquire, align 4 | ||
ret i32 %ret | ||
} | ||
|
||
define ptr @atomic_vector_ptr() { | ||
; CHECK-LABEL: define ptr @atomic_vector_ptr() { | ||
; CHECK-NEXT: [[VAL_SROA_0:%.*]] = alloca <1 x ptr>, align 8 | ||
; CHECK-NEXT: store <1 x ptr> undef, ptr [[VAL_SROA_0]], align 8 | ||
; CHECK-NEXT: [[VAL_SROA_0_0_VAL_SROA_0_0_RET:%.*]] = load atomic volatile ptr, ptr [[VAL_SROA_0]] acquire, align 4 | ||
; CHECK-NEXT: ret ptr [[VAL_SROA_0_0_VAL_SROA_0_0_RET]] | ||
; | ||
%src = alloca <1 x ptr> | ||
%val = alloca <1 x ptr> | ||
%direct = alloca ptr | ||
call void @llvm.memcpy.p0.p0.i64(ptr %val, ptr %src, i64 8, i1 false) | ||
store ptr %val, ptr %direct | ||
%indirect = load ptr, ptr %direct | ||
%ret = load atomic volatile ptr, ptr %indirect acquire, align 4 | ||
ret ptr %ret | ||
} | ||
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. Test a <2 x i16> or some other real vector. 1 x is a degenerate case |
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.
Direct return of boolean expression