[PATCH] D90391: [gvn] PRE needs to skip convergent intrinsics/calls.
Michael Liao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 29 06:38:15 PDT 2020
hliao updated this revision to Diff 301599.
hliao added a comment.
Revise the comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90391/new/
https://reviews.llvm.org/D90391
Files:
llvm/lib/Transforms/Scalar/GVN.cpp
llvm/test/Transforms/GVN/pre-skip-convergent.ll
Index: llvm/test/Transforms/GVN/pre-skip-convergent.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/GVN/pre-skip-convergent.ll
@@ -0,0 +1,25 @@
+; RUN: opt -S -gvn -o - %s | FileCheck %s
+
+; CHECK-LABEL: @foo
+; CHECK: pre:
+; CHECK-NOT: call i32 @llvm.convergent
+; CHECK: merge:
+define i32 @foo(i1 %cond, i32* %q, i32* %p) {
+entry:
+ %v0 = call i32 @llvm.convergent(i32 0)
+ store i32 %v0, i32* %q
+ br i1 %cond, label %pre, label %merge
+
+pre:
+ %t0 = load i32, i32* %p
+ br label %merge
+
+merge:
+ %m0 = phi i32 [ %t0, %pre ], [ 0, %entry ]
+ %r0 = call i32 @llvm.convergent(i32 %m0)
+ ret i32 %r0
+}
+
+declare i32 @llvm.convergent(i32) #0
+
+attributes #0 = { convergent nounwind readnone }
Index: llvm/lib/Transforms/Scalar/GVN.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/GVN.cpp
+++ llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2460,10 +2460,14 @@
if (isa<GetElementPtrInst>(CurInst))
return false;
- // We don't currently value number ANY inline asm calls.
- if (auto *CallB = dyn_cast<CallBase>(CurInst))
+ if (auto *CallB = dyn_cast<CallBase>(CurInst)) {
+ // We don't currently value number ANY inline asm calls.
if (CallB->isInlineAsm())
return false;
+ // Don't do PRE on convergent calls.
+ if (CallB->isConvergent())
+ return false;
+ }
uint32_t ValNo = VN.lookup(CurInst);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90391.301599.patch
Type: text/x-patch
Size: 1465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201029/b1333d73/attachment.bin>
More information about the llvm-commits
mailing list