[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
This commit is contained in:
Craig Topper 2017-04-20 22:57:36 +00:00
parent ac0ecde9f0
commit 7a610e66b2

View File

@ -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(