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:  common.ret:
8; CHECK-NEXT:    store i32 7, i32* [[P:%.*]], align 4
9; CHECK-NEXT:    ret void
10;
11  br i1 %C, label %T, label %F
12T:              ; preds = %0
13  store i32 7, i32* %P
14  ret void
15F:              ; preds = %0
16  store i32 7, i32* %P
17  ret void
18}
19
20define float @PR39535min(float %x) {
21; CHECK-LABEL: @PR39535min(
22; CHECK-NEXT:  entry:
23; CHECK-NEXT:    [[TOBOOL:%.*]] = fcmp une float [[X:%.*]], 0.000000e+00
24; CHECK-NEXT:    [[DOTX:%.*]] = select fast i1 [[TOBOOL]], float 0.000000e+00, float [[X]]
25; CHECK-NEXT:    ret float [[DOTX]]
26;
27entry:
28  %tobool = fcmp une float %x, 0.0
29  br i1 %tobool, label %cond.true, label %cond.false
30
31cond.true:
32  br label %cond.end
33
34cond.false:
35  br label %cond.end
36
37cond.end:
38  %cond = phi fast float [ 0.0, %cond.true ], [ %x, %cond.false ]
39  ret float %cond
40}
41