-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Local: Handle noalias_addrspace in combineMetadata #103938
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
Changes from all commits
db48e2b
74dc3db
59eaca4
dfb1b83
30defe0
3918491
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,12 +39,14 @@ void ConstantRangeList::insert(const ConstantRange &NewRange) { | |
return; | ||
assert(!NewRange.isFullSet() && "Do not support full set"); | ||
assert(NewRange.getLower().slt(NewRange.getUpper())); | ||
assert(getBitWidth() == NewRange.getBitWidth()); | ||
// Handle common cases. | ||
if (empty() || Ranges.back().getUpper().slt(NewRange.getLower())) { | ||
Ranges.push_back(NewRange); | ||
return; | ||
} | ||
|
||
assert(getBitWidth() == NewRange.getBitWidth()); | ||
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. I notice we're moving a bunch of asserts around. I think that needs explaining in the commit message. However, it feels like something's wrong. Does 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. An empty range has no bitwidth. I don't think it's worth adding an explicit field for bit width to give a bit width to the empty range 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. I agree that an empty range has no bitwidth. I missed that I think a good way of expressing this would be to keep the asserts where they are but have |
||
|
||
if (NewRange.getUpper().slt(Ranges.front().getLower())) { | ||
Ranges.insert(Ranges.begin(), NewRange); | ||
return; | ||
|
@@ -142,14 +144,15 @@ void ConstantRangeList::subtract(const ConstantRange &SubRange) { | |
|
||
ConstantRangeList | ||
ConstantRangeList::unionWith(const ConstantRangeList &CRL) const { | ||
assert(getBitWidth() == CRL.getBitWidth() && | ||
"ConstantRangeList bitwidths don't agree!"); | ||
// Handle common cases. | ||
if (empty()) | ||
return CRL; | ||
if (CRL.empty()) | ||
return *this; | ||
|
||
assert(getBitWidth() == CRL.getBitWidth() && | ||
"ConstantRangeList bitwidths don't agree!"); | ||
|
||
ConstantRangeList Result; | ||
size_t i = 0, j = 0; | ||
// "PreviousRange" tracks the lowest unioned range that is being processed. | ||
|
@@ -192,15 +195,15 @@ ConstantRangeList::unionWith(const ConstantRangeList &CRL) const { | |
|
||
ConstantRangeList | ||
ConstantRangeList::intersectWith(const ConstantRangeList &CRL) const { | ||
assert(getBitWidth() == CRL.getBitWidth() && | ||
"ConstantRangeList bitwidths don't agree!"); | ||
|
||
// Handle common cases. | ||
if (empty()) | ||
return *this; | ||
if (CRL.empty()) | ||
return CRL; | ||
|
||
assert(getBitWidth() == CRL.getBitWidth() && | ||
"ConstantRangeList bitwidths don't agree!"); | ||
|
||
ConstantRangeList Result; | ||
size_t i = 0, j = 0; | ||
while (i < size() && j < CRL.size()) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -passes='early-cse<memssa>' -S < %s | FileCheck %s | ||
|
||
declare void @use(i1) | ||
declare void @use.ptr(ptr) memory(read) | ||
|
||
define void @load_first_noalias_addrspace(ptr %p) { | ||
; CHECK-LABEL: define void @load_first_noalias_addrspace( | ||
; CHECK-SAME: ptr [[P:%.*]]) { | ||
; CHECK-NEXT: [[V1:%.*]] = load ptr, ptr [[P]], align 8, !nonnull [[META0:![0-9]+]], !noundef [[META0]], !noalias.addrspace [[META1:![0-9]+]] | ||
; CHECK-NEXT: call void @use.ptr(ptr [[V1]]) | ||
; CHECK-NEXT: call void @use.ptr(ptr [[V1]]) | ||
; CHECK-NEXT: ret void | ||
; | ||
%v1 = load ptr, ptr %p, !nonnull !{}, !noundef !{}, !noalias.addrspace !0 | ||
call void @use.ptr(ptr %v1) | ||
%v2 = load ptr, ptr %p | ||
call void @use.ptr(ptr %v2) | ||
ret void | ||
} | ||
|
||
define void @load_both_same_noalias_addrspace(ptr %p) { | ||
; CHECK-LABEL: define void @load_both_same_noalias_addrspace( | ||
; CHECK-SAME: ptr [[P:%.*]]) { | ||
; CHECK-NEXT: [[V1:%.*]] = load ptr, ptr [[P]], align 8, !nonnull [[META0]], !noundef [[META0]], !noalias.addrspace [[META1]] | ||
; CHECK-NEXT: call void @use.ptr(ptr [[V1]]) | ||
; CHECK-NEXT: call void @use.ptr(ptr [[V1]]) | ||
; CHECK-NEXT: ret void | ||
; | ||
%v1 = load ptr, ptr %p, !nonnull !{}, !noundef !{}, !noalias.addrspace !0 | ||
call void @use.ptr(ptr %v1) | ||
%v2 = load ptr, ptr %p, !noalias.addrspace !0 | ||
call void @use.ptr(ptr %v2) | ||
ret void | ||
} | ||
|
||
define void @load_both_disjoint_noalias_addrspace(ptr %p) { | ||
; CHECK-LABEL: define void @load_both_disjoint_noalias_addrspace( | ||
; CHECK-SAME: ptr [[P:%.*]]) { | ||
; CHECK-NEXT: [[V1:%.*]] = load ptr, ptr [[P]], align 8, !nonnull [[META0]], !noundef [[META0]], !noalias.addrspace [[META1]] | ||
; CHECK-NEXT: call void @use.ptr(ptr [[V1]]) | ||
; CHECK-NEXT: call void @use.ptr(ptr [[V1]]) | ||
; CHECK-NEXT: ret void | ||
; | ||
%v1 = load ptr, ptr %p, !nonnull !{}, !noundef !{}, !noalias.addrspace !0 | ||
call void @use.ptr(ptr %v1) | ||
%v2 = load ptr, ptr %p, !noalias.addrspace !1 | ||
call void @use.ptr(ptr %v2) | ||
ret void | ||
} | ||
|
||
define void @load_both_overlap_noalias_addrspace(ptr %p) { | ||
; CHECK-LABEL: define void @load_both_overlap_noalias_addrspace( | ||
; CHECK-SAME: ptr [[P:%.*]]) { | ||
; CHECK-NEXT: [[V1:%.*]] = load ptr, ptr [[P]], align 8, !nonnull [[META0]], !noundef [[META0]], !noalias.addrspace [[META1]] | ||
; CHECK-NEXT: call void @use.ptr(ptr [[V1]]) | ||
; CHECK-NEXT: call void @use.ptr(ptr [[V1]]) | ||
; CHECK-NEXT: ret void | ||
; | ||
%v1 = load ptr, ptr %p, !nonnull !{}, !noundef !{}, !noalias.addrspace !0 | ||
call void @use.ptr(ptr %v1) | ||
%v2 = load ptr, ptr %p, !noalias.addrspace !2 | ||
call void @use.ptr(ptr %v2) | ||
ret void | ||
} | ||
|
||
!0 = !{i32 5, i32 6} | ||
!1 = !{i32 7, i32 8} | ||
!2 = !{i32 5, i32 7} | ||
;. | ||
; CHECK: [[META0]] = !{} | ||
; CHECK: [[META1]] = !{i32 5, i32 6} | ||
;. |
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.
If the range list is empty, should this continue to return 64? Otherwise at best it'll assert and at worst it'll return garbage. An
optional
could also represent this scenario.If there's a new precondition that you can only call
getBitWidth
on a non-empty range, that should be documented.