[llvm] 0bb698a - [InstCombine] Add additional test for phi to condition fold (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 1 07:10:01 PST 2022


Author: Nikita Popov
Date: 2022-03-01T16:08:47+01:00
New Revision: 0bb698a2fb7021567aae0e43c5aaac167fbb57e6

URL: https://github.com/llvm/llvm-project/commit/0bb698a2fb7021567aae0e43c5aaac167fbb57e6
DIFF: https://github.com/llvm/llvm-project/commit/0bb698a2fb7021567aae0e43c5aaac167fbb57e6.diff

LOG: [InstCombine] Add additional test for phi to condition fold (NFC)

This one does not have an intermediate block for the true branch,
and demonstrates the importance of using edge dominance.

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/simple_phi_condition.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/simple_phi_condition.ll b/llvm/test/Transforms/InstCombine/simple_phi_condition.ll
index 8a3ea4ca4c277..27e2a0142f974 100644
--- a/llvm/test/Transforms/InstCombine/simple_phi_condition.ll
+++ b/llvm/test/Transforms/InstCombine/simple_phi_condition.ll
@@ -52,6 +52,26 @@ merge:
   ret i1 %ret
 }
 
+define i1 @test_edge_dominance(i1 %cmp) {
+; CHECK-LABEL: @test_edge_dominance(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br i1 [[CMP:%.*]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
+; CHECK:       if.then:
+; CHECK-NEXT:    br label [[IF_END]]
+; CHECK:       if.end:
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+entry:
+  br i1 %cmp, label %if.end, label %if.then
+
+if.then:
+  br label %if.end
+
+if.end:
+  %phi = phi i1 [ true, %entry ], [ false, %if.then ]
+  ret i1 %phi
+}
+
 define i1 @test_direct_implication_complex_cfg(i1 %cond, i32 %cnt1) {
 ; CHECK-LABEL: @test_direct_implication_complex_cfg(
 ; CHECK-NEXT:  entry:


        


More information about the llvm-commits mailing list