[llvm] 989ee11 - [Test] Add test that shows how SimplifyCFG may insert redunant Phi

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 16 02:23:39 PDT 2020


Author: Max Kazantsev
Date: 2020-07-16T16:23:11+07:00
New Revision: 989ee11df6814465714f6292424f9e10668c7755

URL: https://github.com/llvm/llvm-project/commit/989ee11df6814465714f6292424f9e10668c7755
DIFF: https://github.com/llvm/llvm-project/commit/989ee11df6814465714f6292424f9e10668c7755.diff

LOG: [Test] Add test that shows how SimplifyCFG may insert redunant Phi

It happens when a block cannot be threaded because of a convergent function.

Added: 
    llvm/test/Transforms/SimplifyCFG/convergent.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SimplifyCFG/convergent.ll b/llvm/test/Transforms/SimplifyCFG/convergent.ll
new file mode 100644
index 000000000000..be8e8482e94b
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/convergent.ll
@@ -0,0 +1,44 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -simplifycfg < %s | FileCheck %s
+; RUN: opt -S -passes=simplify-cfg < %s | FileCheck %s
+
+declare void @foo() convergent
+
+; FIXME: We should not be inserting a PR Phi here.
+define i32 @test_01(i32 %a) {
+; CHECK-LABEL: @test_01(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[COND:%.*]] = icmp eq i32 [[A:%.*]], 0
+; CHECK-NEXT:    br i1 [[COND]], label [[MERGE:%.*]], label [[IF_FALSE:%.*]]
+; CHECK:       if.false:
+; CHECK-NEXT:    call void @foo()
+; CHECK-NEXT:    br label [[MERGE]]
+; CHECK:       merge:
+; CHECK-NEXT:    [[COND_PR:%.*]] = phi i1 [ [[COND]], [[IF_FALSE]] ], [ true, [[ENTRY:%.*]] ]
+; CHECK-NEXT:    call void @foo()
+; CHECK-NEXT:    br i1 [[COND_PR]], label [[EXIT:%.*]], label [[IF_FALSE_2:%.*]]
+; CHECK:       if.false.2:
+; CHECK-NEXT:    call void @foo()
+; CHECK-NEXT:    br label [[EXIT]]
+; CHECK:       exit:
+; CHECK-NEXT:    ret i32 [[A]]
+;
+entry:
+  %cond = icmp eq i32 %a, 0
+  br i1 %cond, label %merge, label %if.false
+
+if.false:
+  call void @foo()
+  br label %merge
+
+merge:
+  call void @foo()
+  br i1 %cond, label %exit, label %if.false.2
+
+if.false.2:
+  call void @foo()
+  br label %exit
+
+exit:
+  ret i32 %a
+}


        


More information about the llvm-commits mailing list