[PATCH] D30921: SimplifyCFG: SinkThenElseCode shouldn't sink convergent functions

Tom Stellard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 13 16:42:37 PDT 2017


tstellar created this revision.
Herald added a subscriber: wdng.

https://reviews.llvm.org/D30921

Files:
  lib/Transforms/Utils/SimplifyCFG.cpp
  test/Transforms/SimplifyCFG/sink-common-code.ll


Index: test/Transforms/SimplifyCFG/sink-common-code.ll
===================================================================
--- test/Transforms/SimplifyCFG/sink-common-code.ll
+++ test/Transforms/SimplifyCFG/sink-common-code.ll
@@ -818,6 +818,31 @@
 ; CHECK: right:
 ; CHECK-NEXT:   %val1 = call i32 @call_target() [ "deopt"(i32 20) ]
 
+declare i32 @convergent_call(i32)
+
+define i32 @test_no_sink_convergent(i1 %cond) {
+entry:
+  br i1 %cond, label %if.then, label %if.else
+
+if.then:
+  %tmp0 = call i32 @convergent_call(i32 0) #0
+  br label %if.end
+
+if.else:
+  %tmp1 = call i32 @convergent_call(i32 1) #0
+  br label %if.end
+
+if.end:
+  %tmp2 = phi i32 [%tmp0, %if.then], [%tmp1, %if.else]
+  ret i32 %tmp2
+}
+
+; CHECK-LABEL: @convergent_call
+; CHECK: @convergent_call(i32 0)
+; CHECK: @convergent_call(i32 1)
+
+attributes #0 = { convergent }
+
 ; CHECK: ![[TBAA]] = !{![[TYPE:[0-9]]], ![[TYPE]], i64 0}
 ; CHECK: ![[TYPE]] = !{!"float", ![[TEXT:[0-9]]]}
 ; CHECK: ![[TEXT]] = !{!"an example type tree"}
Index: lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- lib/Transforms/Utils/SimplifyCFG.cpp
+++ lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1442,7 +1442,7 @@
     // and merging inline-asm instructions can potentially create arguments
     // that cannot satisfy the inline-asm constraints.
     if (const auto *C = dyn_cast<CallInst>(I))
-      if (C->isInlineAsm())
+      if (C->isInlineAsm() || C->isConvergent())
         return false;
 
     // Everything must have only one use too, apart from stores which


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30921.91647.patch
Type: text/x-patch
Size: 1592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170313/7feaa0ed/attachment.bin>


More information about the llvm-commits mailing list