-; RUN: opt -S -simplifycfg < %s | FileCheck %s --check-prefix=EXPENSIVE --check-prefix=ALL
-; RUN: opt -S -simplifycfg -speculate-one-expensive-inst=false < %s | FileCheck %s --check-prefix=CHEAP --check-prefix=ALL
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -simplifycfg < %s | FileCheck %s --check-prefix=ALL --check-prefix=EXPENSIVE
+; RUN: opt -S -simplifycfg -speculate-one-expensive-inst=false < %s | FileCheck %s --check-prefix=ALL --check-prefix=CHEAP
declare float @llvm.sqrt.f32(float) nounwind readonly
declare float @llvm.fma.f32(float, float, float) nounwind readonly
declare float @llvm.minimum.f32(float, float) nounwind readonly
declare float @llvm.maximum.f32(float, float) nounwind readonly
-; ALL-LABEL: @fdiv_test(
-; EXPENSIVE: select i1 %cmp, double %div, double 0.0
-; CHEAP-NOT: select
-
define double @fdiv_test(double %a, double %b) {
+; EXPENSIVE-LABEL: @fdiv_test(
+; EXPENSIVE-NEXT: entry:
+; EXPENSIVE-NEXT: [[CMP:%.*]] = fcmp ogt double [[A:%.*]], 0.000000e+00
+; EXPENSIVE-NEXT: [[DIV:%.*]] = fdiv double [[B:%.*]], [[A]]
+; EXPENSIVE-NEXT: [[COND:%.*]] = select i1 [[CMP]], double [[DIV]], double 0.000000e+00
+; EXPENSIVE-NEXT: ret double [[COND]]
+;
+; CHEAP-LABEL: @fdiv_test(
+; CHEAP-NEXT: entry:
+; CHEAP-NEXT: [[CMP:%.*]] = fcmp ogt double [[A:%.*]], 0.000000e+00
+; CHEAP-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[COND_END:%.*]]
+; CHEAP: cond.true:
+; CHEAP-NEXT: [[DIV:%.*]] = fdiv double [[B:%.*]], [[A]]
+; CHEAP-NEXT: br label [[COND_END]]
+; CHEAP: cond.end:
+; CHEAP-NEXT: [[COND:%.*]] = phi double [ [[DIV]], [[COND_TRUE]] ], [ 0.000000e+00, [[ENTRY:%.*]] ]
+; CHEAP-NEXT: ret double [[COND]]
+;
entry:
%cmp = fcmp ogt double %a, 0.0
br i1 %cmp, label %cond.true, label %cond.end
ret double %cond
}
-; ALL-LABEL: @sqrt_test(
-; ALL: select
define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
+; ALL-LABEL: @sqrt_test(
+; ALL-NEXT: entry:
+; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
+; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.sqrt.f32(float [[A]]) #2
+; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
+; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
+; ALL-NEXT: ret void
+;
entry:
%cmp.i = fcmp olt float %a, 0.000000e+00
br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i
ret void
}
-; ALL-LABEL: @fabs_test(
-; ALL: select
define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
+; ALL-LABEL: @fabs_test(
+; ALL-NEXT: entry:
+; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
+; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.fabs.f32(float [[A]]) #2
+; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
+; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
+; ALL-NEXT: ret void
+;
entry:
%cmp.i = fcmp olt float %a, 0.000000e+00
br i1 %cmp.i, label %test_fabs.exit, label %cond.else.i
ret void
}
-; ALL-LABEL: @fma_test(
-; ALL: select
define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
+; ALL-LABEL: @fma_test(
+; ALL-NEXT: entry:
+; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
+; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.fma.f32(float [[A]], float [[B:%.*]], float [[C:%.*]]) #2
+; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
+; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
+; ALL-NEXT: ret void
+;
entry:
%cmp.i = fcmp olt float %a, 0.000000e+00
br i1 %cmp.i, label %test_fma.exit, label %cond.else.i
ret void
}
-; ALL-LABEL: @fmuladd_test(
-; ALL: select
define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
+; ALL-LABEL: @fmuladd_test(
+; ALL-NEXT: entry:
+; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
+; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.fmuladd.f32(float [[A]], float [[B:%.*]], float [[C:%.*]]) #2
+; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
+; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
+; ALL-NEXT: ret void
+;
entry:
%cmp.i = fcmp olt float %a, 0.000000e+00
br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i
ret void
}
-; ALL-LABEL: @minnum_test(
-; ALL: select
define void @minnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
+; ALL-LABEL: @minnum_test(
+; ALL-NEXT: entry:
+; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
+; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.minnum.f32(float [[A]], float [[B:%.*]]) #2
+; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
+; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
+; ALL-NEXT: ret void
+;
entry:
%cmp.i = fcmp olt float %a, 0.000000e+00
br i1 %cmp.i, label %test_minnum.exit, label %cond.else.i
ret void
}
-; ALL-LABEL: @maxnum_test(
-; ALL: select
define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
+; ALL-LABEL: @maxnum_test(
+; ALL-NEXT: entry:
+; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
+; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.maxnum.f32(float [[A]], float [[B:%.*]]) #2
+; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
+; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
+; ALL-NEXT: ret void
+;
entry:
%cmp.i = fcmp olt float %a, 0.000000e+00
br i1 %cmp.i, label %test_maxnum.exit, label %cond.else.i
ret void
}
-; ALL-LABEL: @minimum_test(
-; ALL: select
define void @minimum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
+; ALL-LABEL: @minimum_test(
+; ALL-NEXT: entry:
+; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
+; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.minimum.f32(float [[A]], float [[B:%.*]]) #2
+; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
+; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
+; ALL-NEXT: ret void
+;
entry:
%cmp.i = fcmp olt float %a, 0.000000e+00
br i1 %cmp.i, label %test_minimum.exit, label %cond.else.i
ret void
}
-; ALL-LABEL: @maximum_test(
-; ALL: select
define void @maximum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
+; ALL-LABEL: @maximum_test(
+; ALL-NEXT: entry:
+; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
+; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.maximum.f32(float [[A]], float [[B:%.*]]) #2
+; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
+; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4
+; ALL-NEXT: ret void
+;
entry:
%cmp.i = fcmp olt float %a, 0.000000e+00
br i1 %cmp.i, label %test_maximum.exit, label %cond.else.i