From: Craig Topper Date: Thu, 20 Apr 2017 22:57:36 +0000 (+0000) Subject: [Simplify] Add testcase to show that merging conditional stores for triangles is... X-Git-Tag: android-x86-7.1-r4~17399 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7a610e66b278e5b72574f9a5b5bb2fc7bc7a5a7c;p=android-x86%2Fexternal-llvm.git [Simplify] Add testcase to show that merging conditional stores for triangles is sensitive to the order of the branch targets on the conditional branches. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300915 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/SimplifyCFG/merge-cond-stores.ll b/test/Transforms/SimplifyCFG/merge-cond-stores.ll index d5d0224a4b2..0174abf2b06 100644 --- a/test/Transforms/SimplifyCFG/merge-cond-stores.ll +++ b/test/Transforms/SimplifyCFG/merge-cond-stores.ll @@ -36,6 +36,45 @@ end: ret void } +; This is the same as test_simple, but the branch target order has been swapped +; TODO: This test should succeed and end up if-converted. +define void @test_simple_commuted(i32* %p, i32 %a, i32 %b) { +; CHECK-LABEL: @test_simple_commuted( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[X1:%.*]] = icmp eq i32 [[A:%.*]], 0 +; CHECK-NEXT: br i1 [[X1]], label [[YES1:%.*]], label [[FALLTHROUGH:%.*]] +; CHECK: yes1: +; CHECK-NEXT: store i32 0, i32* [[P:%.*]], align 4 +; CHECK-NEXT: br label [[FALLTHROUGH]] +; CHECK: fallthrough: +; CHECK-NEXT: [[X2:%.*]] = icmp eq i32 [[B:%.*]], 0 +; CHECK-NEXT: br i1 [[X2]], label [[YES2:%.*]], label [[END:%.*]] +; CHECK: yes2: +; CHECK-NEXT: store i32 1, i32* [[P]], align 4 +; CHECK-NEXT: br label [[END]] +; CHECK: end: +; CHECK-NEXT: ret void +; +entry: + %x1 = icmp eq i32 %a, 0 + br i1 %x1, label %yes1, label %fallthrough + +yes1: + store i32 0, i32* %p + br label %fallthrough + +fallthrough: + %x2 = icmp eq i32 %b, 0 + br i1 %x2, label %yes2, label %end + +yes2: + store i32 1, i32* %p + br label %end + +end: + ret void +} + ; This test should entirely fold away, leaving one large basic block. define void @test_recursive(i32* %p, i32 %a, i32 %b, i32 %c, i32 %d) { ; CHECK-LABEL: @test_recursive(