From: Roman Lebedev Date: Sat, 7 Sep 2019 09:25:26 +0000 (+0000) Subject: [SimplifyCFG][NFC] Show that we don't consider the cost when merging cond stores X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=781f9079d19d24424f2ce9ec8d42aca39d25ad6c;p=llvm [SimplifyCFG][NFC] Show that we don't consider the cost when merging cond stores We count instruction count in each BB's separately, not their cost. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371297 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/SimplifyCFG/merge-cond-stores.ll b/test/Transforms/SimplifyCFG/merge-cond-stores.ll index 75767a09216..0ea46bf72f2 100644 --- a/test/Transforms/SimplifyCFG/merge-cond-stores.ll +++ b/test/Transforms/SimplifyCFG/merge-cond-stores.ll @@ -415,3 +415,39 @@ end: ret void } +define void @test_costly(i32* %p, i32 %a, i32 %b, i32 %c, i32 %d) { +; CHECK-LABEL: @test_costly( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[X1:%.*]] = icmp ne i32 [[A:%.*]], 0 +; CHECK-NEXT: [[X2:%.*]] = icmp eq i32 [[B:%.*]], 0 +; CHECK-NEXT: [[TMP0:%.*]] = xor i1 [[X2]], true +; CHECK-NEXT: [[TMP1:%.*]] = or i1 [[X1]], [[TMP0]] +; CHECK-NEXT: br i1 [[TMP1]], label [[TMP2:%.*]], label [[TMP3:%.*]] +; CHECK: 2: +; CHECK-NEXT: [[VAL:%.*]] = sdiv i32 [[C:%.*]], [[D:%.*]] +; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[X2]], i32 0, i32 [[VAL]] +; CHECK-NEXT: store i32 [[SPEC_SELECT]], i32* [[P:%.*]], align 4 +; CHECK-NEXT: br label [[TMP3]] +; CHECK: 3: +; CHECK-NEXT: ret void +; +entry: + %x1 = icmp eq i32 %a, 0 + br i1 %x1, label %fallthrough, label %yes1 + +yes1: + store i32 0, i32* %p + br label %fallthrough + +fallthrough: + %x2 = icmp eq i32 %b, 0 + %val = sdiv i32 %c, %d + br i1 %x2, label %end, label %yes2 + +yes2: + store i32 %val, i32* %p + br label %end + +end: + ret void +}