Skip to content

[Local] Only intersect alias.scope,noalias & parallel_loop if inst moves #117716

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 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions llvm/lib/Transforms/Utils/Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3330,11 +3330,13 @@ void llvm::combineMetadata(Instruction *K, const Instruction *J,
K->setMetadata(Kind, MDNode::getMostGenericTBAA(JMD, KMD));
break;
case LLVMContext::MD_alias_scope:
K->setMetadata(Kind, MDNode::getMostGenericAliasScope(JMD, KMD));
if (DoesKMove)
K->setMetadata(Kind, MDNode::getMostGenericAliasScope(JMD, KMD));
break;
case LLVMContext::MD_noalias:
case LLVMContext::MD_mem_parallel_loop_access:
K->setMetadata(Kind, MDNode::intersect(JMD, KMD));
if (DoesKMove)
K->setMetadata(Kind, MDNode::intersect(JMD, KMD));
break;
case LLVMContext::MD_access_group:
if (DoesKMove)
Expand Down
7 changes: 3 additions & 4 deletions llvm/test/Transforms/GVN/noalias.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

define i32 @test1(ptr %p, ptr %q) {
; CHECK-LABEL: @test1(ptr %p, ptr %q)
; CHECK: load i32, ptr %p
; CHECK-NOT: noalias
; CHECK: load i32, ptr %p, align 4, !noalias ![[SCOPE1:[0-9]+]]
; CHECK: %c = add i32 %a, %a
%a = load i32, ptr %p, !noalias !3
%b = load i32, ptr %p
Expand All @@ -13,7 +12,7 @@ define i32 @test1(ptr %p, ptr %q) {

define i32 @test2(ptr %p, ptr %q) {
; CHECK-LABEL: @test2(ptr %p, ptr %q)
; CHECK: load i32, ptr %p, align 4, !alias.scope ![[SCOPE1:[0-9]+]]
; CHECK: load i32, ptr %p, align 4, !alias.scope ![[SCOPE1]]
; CHECK: %c = add i32 %a, %a
%a = load i32, ptr %p, !alias.scope !3
%b = load i32, ptr %p, !alias.scope !3
Expand All @@ -32,7 +31,7 @@ define i32 @test3(ptr %p, ptr %q) {
}

; CHECK: ![[SCOPE1]] = !{!{{[0-9]+}}}
; CHECK: ![[SCOPE2]] = !{!{{[0-9]+}}, !{{[0-9]+}}}
; CHECK: ![[SCOPE2]] = !{!{{[0-9]+}}}
declare i32 @foo(ptr) readonly

!0 = distinct !{!0, !2, !"callee0: %a"}
Expand Down
9 changes: 6 additions & 3 deletions llvm/test/Transforms/InstCombine/loadstore-metadata.ll
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ entry:
define double @preserve_load_metadata_after_select_transform_metadata_missing_4(ptr %a, ptr %b) {
; CHECK-LABEL: @preserve_load_metadata_after_select_transform_metadata_missing_4(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[L_A:%.*]] = load double, ptr [[A:%.*]], align 8, !tbaa [[TBAA0]], !llvm.access.group [[META6]]
; CHECK-NEXT: [[L_B:%.*]] = load double, ptr [[B:%.*]], align 8, !tbaa [[TBAA0]], !llvm.access.group [[ACC_GRP10:![0-9]+]]
; CHECK-NEXT: [[L_A:%.*]] = load double, ptr [[A:%.*]], align 8, !tbaa [[TBAA0]], !alias.scope [[META3]], !noalias [[META3]], !llvm.access.group [[META6]]
; CHECK-NEXT: [[L_B:%.*]] = load double, ptr [[B:%.*]], align 8, !tbaa [[TBAA0]], !alias.scope [[META10:![0-9]+]], !noalias [[META10]], !llvm.access.group [[ACC_GRP13:![0-9]+]]
; CHECK-NEXT: [[CMP_I:%.*]] = fcmp fast olt double [[L_A]], [[L_B]]
; CHECK-NEXT: [[L_SEL:%.*]] = select i1 [[CMP_I]], double [[L_B]], double [[L_A]]
; CHECK-NEXT: ret double [[L_SEL]]
Expand Down Expand Up @@ -322,5 +322,8 @@ entry:
; CHECK: [[META7]] = !{i32 1}
; CHECK: [[META8]] = !{i64 8}
; CHECK: [[ACC_GRP9]] = distinct !{}
; CHECK: [[ACC_GRP10]] = distinct !{}
; CHECK: [[META10]] = !{[[META11:![0-9]+]]}
; CHECK: [[META11]] = distinct !{[[META11]], [[META12:![0-9]+]]}
; CHECK: [[META12]] = distinct !{[[META12]]}
; CHECK: [[ACC_GRP13]] = distinct !{}
;.
9 changes: 7 additions & 2 deletions llvm/test/Transforms/JumpThreading/thread-loads.ll
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ bb3:
define void @test8(ptr, ptr, ptr) {
; CHECK-LABEL: @test8(
; CHECK-NEXT: ret2:
; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[TMP0:%.*]], align 4, !tbaa [[TBAA0]], !range [[RNG4:![0-9]+]], !noundef [[META5:![0-9]+]]
; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[TMP0:%.*]], align 4, !tbaa [[TBAA0]], !range [[RNG4:![0-9]+]], !alias.scope [[META5:![0-9]+]], !noalias [[META8:![0-9]+]], !noundef [[META10:![0-9]+]]
; CHECK-NEXT: store i32 [[A]], ptr [[TMP1:%.*]], align 4
; CHECK-NEXT: [[XXX:%.*]] = tail call i32 (...) @f1() #[[ATTR0]]
; CHECK-NEXT: ret void
Expand Down Expand Up @@ -698,5 +698,10 @@ right_x:
; CHECK: [[META2]] = !{!"omnipotent char", [[META3:![0-9]+]]}
; CHECK: [[META3]] = !{!"Simple C/C++ TBAA"}
; CHECK: [[RNG4]] = !{i32 0, i32 1}
; CHECK: [[META5]] = !{}
; CHECK: [[META5]] = !{[[META6:![0-9]+]]}
; CHECK: [[META6]] = distinct !{[[META6]], [[META7:![0-9]+]]}
; CHECK: [[META7]] = distinct !{[[META7]]}
; CHECK: [[META8]] = !{[[META9:![0-9]+]]}
; CHECK: [[META9]] = distinct !{[[META9]], [[META7]]}
; CHECK: [[META10]] = !{}
;.
6 changes: 3 additions & 3 deletions llvm/test/Transforms/NewGVN/noalias.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
define i32 @test1(ptr %p, ptr %q) {
; CHECK-LABEL: define i32 @test1(
; CHECK-SAME: ptr [[P:%.*]], ptr [[Q:%.*]]) {
; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[P]], align 4
; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[P]], align 4, !noalias [[META0:![0-9]+]]
; CHECK-NEXT: [[C:%.*]] = add i32 [[A]], [[A]]
; CHECK-NEXT: ret i32 [[C]]
;
Expand All @@ -17,7 +17,7 @@ define i32 @test1(ptr %p, ptr %q) {
define i32 @test2(ptr %p, ptr %q) {
; CHECK-LABEL: define i32 @test2(
; CHECK-SAME: ptr [[P:%.*]], ptr [[Q:%.*]]) {
; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[P]], align 4, !alias.scope [[META0:![0-9]+]]
; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[P]], align 4, !alias.scope [[META0]]
; CHECK-NEXT: [[C:%.*]] = add i32 [[A]], [[A]]
; CHECK-NEXT: ret i32 [[C]]
;
Expand Down Expand Up @@ -53,6 +53,6 @@ declare i32 @foo(ptr) readonly
; CHECK: [[META0]] = !{[[META1:![0-9]+]]}
; CHECK: [[META1]] = distinct !{[[META1]], [[META2:![0-9]+]], !"callee0: %a"}
; CHECK: [[META2]] = distinct !{[[META2]], !"callee0"}
; CHECK: [[META3]] = !{[[META4:![0-9]+]], [[META1]]}
; CHECK: [[META3]] = !{[[META4:![0-9]+]]}
; CHECK: [[META4]] = distinct !{[[META4]], [[META2]], !"callee0: %b"}
;.