[llvm] 4024ca8 - [Test] Add test showing missing simplifycfg opportunity for Phi with undef inputs

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 27 21:23:46 PDT 2021


Author: Max Kazantsev
Date: 2021-10-28T11:23:07+07:00
New Revision: 4024ca892227bbe14e89941e984ead421e569f1c

URL: https://github.com/llvm/llvm-project/commit/4024ca892227bbe14e89941e984ead421e569f1c
DIFF: https://github.com/llvm/llvm-project/commit/4024ca892227bbe14e89941e984ead421e569f1c.diff

LOG: [Test] Add test showing missing simplifycfg opportunity for Phi with undef inputs

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

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SimplifyCFG/undef_phi.ll b/llvm/test/Transforms/SimplifyCFG/undef_phi.ll
new file mode 100644
index 0000000000000..61cabf3cc4eb9
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/undef_phi.ll
@@ -0,0 +1,38 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -simplifycfg -S | FileCheck %s
+; RUN: opt < %s -passes=simplifycfg -S | FileCheck %s
+
+declare void @foo()
+
+; FIXME: We can replace %phi with true.
+define void @test_01(i1 %cond) {
+; CHECK-LABEL: @test_01(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[DOT:%.*]] = select i1 [[COND:%.*]], i1 true, i1 undef
+; CHECK-NEXT:    br i1 [[DOT]], label [[RET_1:%.*]], label [[COMMON_RET:%.*]]
+; CHECK:       common.ret:
+; CHECK-NEXT:    ret void
+; CHECK:       ret_1:
+; CHECK-NEXT:    call void @foo()
+; CHECK-NEXT:    br label [[COMMON_RET]]
+;
+entry:
+  br i1 %cond, label %if.true, label %if.false
+
+if.true:
+  br label %merge
+
+if.false:
+  br label %merge
+
+merge:
+  %phi = phi i1 [true, %if.true], [undef, %if.false]
+  br i1 %phi, label %ret_1, label %ret_2
+
+ret_1:
+  call void @foo()
+  ret void
+
+ret_2:
+  ret void
+}


        


More information about the llvm-commits mailing list