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 -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -hoist-common-insts=true -S | FileCheck %s
5 define void @foo(i1 %C, ptr %P) {
7 ; CHECK-NEXT: common.ret:
8 ; CHECK-NEXT: store i32 7, ptr [[P:%.*]], align 4
11 br i1 %C, label %T, label %F
20 define void @foo_switch(i64 %C, ptr %P) {
21 ; CHECK-LABEL: @foo_switch(
22 ; CHECK-NEXT: common.ret:
23 ; CHECK-NEXT: store i32 7, ptr [[P:%.*]], align 4
24 ; CHECK-NEXT: ret void
26 switch i64 %C, label %bb0 [
41 define float @PR39535min(float %x) {
42 ; CHECK-LABEL: @PR39535min(
44 ; CHECK-NEXT: [[TOBOOL:%.*]] = fcmp une float [[X:%.*]], 0.000000e+00
45 ; CHECK-NEXT: [[DOTX:%.*]] = select fast i1 [[TOBOOL]], float 0.000000e+00, float [[X]]
46 ; CHECK-NEXT: ret float [[DOTX]]
49 %tobool = fcmp une float %x, 0.0
50 br i1 %tobool, label %cond.true, label %cond.false
59 %cond = phi fast float [ 0.0, %cond.true ], [ %x, %cond.false ]
63 define float @PR39535min_switch(i64 %i, float %x) {
64 ; CHECK-LABEL: @PR39535min_switch(
66 ; CHECK-NEXT: switch i64 [[I:%.*]], label [[END:%.*]] [
67 ; CHECK-NEXT: i64 1, label [[BB1:%.*]]
68 ; CHECK-NEXT: i64 2, label [[BB2:%.*]]
71 ; CHECK-NEXT: br label [[END]]
73 ; CHECK-NEXT: br label [[END]]
75 ; CHECK-NEXT: [[COND:%.*]] = phi fast float [ [[X:%.*]], [[BB1]] ], [ [[X]], [[BB2]] ], [ 0.000000e+00, [[ENTRY:%.*]] ]
76 ; CHECK-NEXT: ret float [[COND]]
79 switch i64 %i, label %bb0 [
94 %cond = phi fast float [ 0.0, %bb0 ], [ %x, %bb1 ], [ %x, %bb2 ]
98 define i32 @hoist_zext_flags_preserve(i1 %C, i8 %x) {
99 ; CHECK-LABEL: @hoist_zext_flags_preserve(
100 ; CHECK-NEXT: common.ret:
101 ; CHECK-NEXT: [[Z1:%.*]] = zext nneg i8 [[X:%.*]] to i32
102 ; CHECK-NEXT: ret i32 [[Z1]]
104 br i1 %C, label %T, label %F
106 %z1 = zext nneg i8 %x to i32
109 %z2 = zext nneg i8 %x to i32
113 define i32 @hoist_zext_flags_drop(i1 %C, i8 %x) {
114 ; CHECK-LABEL: @hoist_zext_flags_drop(
115 ; CHECK-NEXT: common.ret:
116 ; CHECK-NEXT: [[Z1:%.*]] = zext i8 [[X:%.*]] to i32
117 ; CHECK-NEXT: ret i32 [[Z1]]
119 br i1 %C, label %T, label %F
121 %z1 = zext nneg i8 %x to i32
124 %z2 = zext i8 %x to i32