[PATCH] D93503: [GVN] Propagate llvm.access.group metadata of loads
KAWASHIMA Takahiro via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 6 17:38:54 PST 2021
kawashima-fj updated this revision to Diff 315029.
kawashima-fj added a comment.
Simplify the test code.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93503/new/
https://reviews.llvm.org/D93503
Files:
llvm/lib/Transforms/Scalar/GVN.cpp
llvm/test/Transforms/GVN/PRE/load-pre-metadata-accsess-group.ll
Index: llvm/test/Transforms/GVN/PRE/load-pre-metadata-accsess-group.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/GVN/PRE/load-pre-metadata-accsess-group.ll
@@ -0,0 +1,33 @@
+; RUN: opt < %s -basic-aa -gvn -enable-load-pre -S | FileCheck %s
+
+define dso_local void @test1(i32* nocapture readonly %aa, i32* nocapture %bb) local_unnamed_addr {
+; CHECK-LABEL: @test1(
+entry:
+ %arrayidx = getelementptr inbounds i32, i32* %bb, i64 1
+ %arrayidx2 = getelementptr inbounds i32, i32* %aa, i64 1
+ %0 = load i32, i32* %arrayidx2, align 4
+ store i32 %0, i32* %arrayidx, align 4
+ br label %for.body
+
+for.body:
+ %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+ %arrayidx4 = getelementptr inbounds i32, i32* %aa, i64 %indvars.iv
+ %1 = load i32, i32* %arrayidx4, align 4, !llvm.access.group !1
+ %2 = load i32, i32* %arrayidx, align 4, !llvm.access.group !1
+ %mul = mul nsw i32 %2, %1
+ store i32 %mul, i32* %arrayidx4, align 4, !llvm.access.group !1
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+ %exitcond = icmp ne i64 %indvars.iv.next, 100
+ br i1 %exitcond, label %for.body, label %for.end, !llvm.loop !2
+
+;CHECK-LABEL: for.body.for.body_crit_edge:
+;CHECK-NEXT: %.pre = load i32, i32* %arrayidx, align 4, !llvm.access.group !0
+
+for.end:
+ ret void
+}
+
+!1 = distinct !{}
+!2 = distinct !{!2, !3, !4}
+!3 = !{!"llvm.loop.parallel_accesses", !1}
+!4 = !{!"llvm.loop.vectorize.enable", i1 true}
Index: llvm/lib/Transforms/Scalar/GVN.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/GVN.cpp
+++ llvm/lib/Transforms/Scalar/GVN.cpp
@@ -1398,6 +1398,10 @@
NewLoad->setMetadata(LLVMContext::MD_invariant_group, InvGroupMD);
if (auto *RangeMD = LI->getMetadata(LLVMContext::MD_range))
NewLoad->setMetadata(LLVMContext::MD_range, RangeMD);
+ if (auto *AccessMD = LI->getMetadata(LLVMContext::MD_access_group))
+ if (this->LI && this->LI->getLoopFor(LI->getParent()) ==
+ this->LI->getLoopFor(UnavailablePred))
+ NewLoad->setMetadata(LLVMContext::MD_access_group, AccessMD);
// We do not propagate the old load's debug location, because the new
// load now lives in a different BB, and we want to avoid a jumpy line
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93503.315029.patch
Type: text/x-patch
Size: 2347 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210107/de5d4bcd/attachment.bin>
More information about the llvm-commits
mailing list