1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=simplifycfg -hoist-common-insts=true -S | FileCheck %s
3; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -hoist-common-insts=true -S | FileCheck %s
4
5define void @foo(i1 %C, i32* %P) {
6; CHECK-LABEL: @foo(
7; CHECK-NEXT:    store i32 7, i32* [[P:%.*]]
8; CHECK-NEXT:    ret void
9;
10  br i1 %C, label %T, label %F
11T:              ; preds = %0
12  store i32 7, i32* %P
13  ret void
14F:              ; preds = %0
15  store i32 7, i32* %P
16  ret void
17}
18
19define float @PR39535min(float %x) {
20; CHECK-LABEL: @PR39535min(
21; CHECK-NEXT:  entry:
22; CHECK-NEXT:    [[TOBOOL:%.*]] = fcmp une float [[X:%.*]], 0.000000e+00
23; CHECK-NEXT:    [[DOTX:%.*]] = select fast i1 [[TOBOOL]], float 0.000000e+00, float [[X]]
24; CHECK-NEXT:    ret float [[DOTX]]
25;
26entry:
27  %tobool = fcmp une float %x, 0.0
28  br i1 %tobool, label %cond.true, label %cond.false
29
30cond.true:
31  br label %cond.end
32
33cond.false:
34  br label %cond.end
35
36cond.end:
37  %cond = phi fast float [ 0.0, %cond.true ], [ %x, %cond.false ]
38  ret float %cond
39}
40