CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
598 lines
24 KiB
LLVM
598 lines
24 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
|
|
|
|
declare void @use(i1)
|
|
declare void @usef64(double)
|
|
declare double @llvm.fabs.f64(double)
|
|
declare <2 x double> @llvm.fabs.v2f64(<2 x double>)
|
|
|
|
; X == 42.0 ? X : 42.0 --> 42.0
|
|
|
|
define double @oeq(double %x) {
|
|
; CHECK-LABEL: @oeq(
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq double [[X:%.*]], 4.200000e+01
|
|
; CHECK-NEXT: call void @use(i1 [[CMP]])
|
|
; CHECK-NEXT: ret double 4.200000e+01
|
|
;
|
|
%cmp = fcmp oeq double %x, 42.0
|
|
call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization
|
|
%cond = select i1 %cmp, double %x, double 42.0
|
|
ret double %cond
|
|
}
|
|
|
|
; X == 42.0 ? 42.0 : X --> X
|
|
|
|
define float @oeq_swapped(float %x) {
|
|
; CHECK-LABEL: @oeq_swapped(
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq float [[X:%.*]], 4.200000e+01
|
|
; CHECK-NEXT: call void @use(i1 [[CMP]])
|
|
; CHECK-NEXT: ret float [[X]]
|
|
;
|
|
%cmp = fcmp oeq float %x, 42.0
|
|
call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization
|
|
%cond = select i1 %cmp, float 42.0, float %x
|
|
ret float %cond
|
|
}
|
|
|
|
; x != y ? x : y -> x if it's the right kind of != and at least
|
|
; one of x and y is not negative zero.
|
|
|
|
; X != 42.0 ? X : 42.0 --> X
|
|
|
|
define double @une(double %x) {
|
|
; CHECK-LABEL: @une(
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[X:%.*]], 4.200000e+01
|
|
; CHECK-NEXT: call void @use(i1 [[CMP]])
|
|
; CHECK-NEXT: ret double [[X]]
|
|
;
|
|
%cmp = fcmp une double %x, 42.0
|
|
call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization
|
|
%cond = select i1 %cmp, double %x, double 42.0
|
|
ret double %cond
|
|
}
|
|
|
|
; X != 42.0 ? 42.0 : X --> 42.0
|
|
|
|
define double @une_swapped(double %x) {
|
|
; CHECK-LABEL: @une_swapped(
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[X:%.*]], 4.200000e+01
|
|
; CHECK-NEXT: call void @use(i1 [[CMP]])
|
|
; CHECK-NEXT: ret double 4.200000e+01
|
|
;
|
|
%cmp = fcmp une double %x, 42.0
|
|
call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization
|
|
%cond = select i1 %cmp, double 42.0, double %x
|
|
ret double %cond
|
|
}
|
|
|
|
define double @une_could_be_negzero(double %x, double %y) {
|
|
; CHECK-LABEL: @une_could_be_negzero(
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[X:%.*]], [[Y:%.*]]
|
|
; CHECK-NEXT: call void @use(i1 [[CMP]])
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], double [[X]], double [[Y]]
|
|
; CHECK-NEXT: ret double [[COND]]
|
|
;
|
|
%cmp = fcmp une double %x, %y
|
|
call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization
|
|
%cond = select i1 %cmp, double %x, double %y
|
|
ret double %cond
|
|
}
|
|
|
|
define double @une_swapped_could_be_negzero(double %x, double %y) {
|
|
; CHECK-LABEL: @une_swapped_could_be_negzero(
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[X:%.*]], [[Y:%.*]]
|
|
; CHECK-NEXT: call void @use(i1 [[CMP]])
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], double [[Y]], double [[X]]
|
|
; CHECK-NEXT: ret double [[COND]]
|
|
;
|
|
%cmp = fcmp une double %x, %y
|
|
call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization
|
|
%cond = select i1 %cmp, double %y, double %x
|
|
ret double %cond
|
|
}
|
|
|
|
define double @one(double %x) {
|
|
; CHECK-LABEL: @one(
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one double [[X:%.*]], -1.000000e+00
|
|
; CHECK-NEXT: call void @use(i1 [[CMP]])
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], double [[X]], double -1.000000e+00
|
|
; CHECK-NEXT: ret double [[COND]]
|
|
;
|
|
%cmp = fcmp one double %x, -1.0
|
|
call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization
|
|
%cond = select i1 %cmp, double %x, double -1.0
|
|
ret double %cond
|
|
}
|
|
|
|
define double @one_swapped(double %x) {
|
|
; CHECK-LABEL: @one_swapped(
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one double [[X:%.*]], -1.000000e+00
|
|
; CHECK-NEXT: call void @use(i1 [[CMP]])
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], double -1.000000e+00, double [[X]]
|
|
; CHECK-NEXT: ret double [[COND]]
|
|
;
|
|
%cmp = fcmp one double %x, -1.0
|
|
call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization
|
|
%cond = select i1 %cmp, double -1.0, double %x
|
|
ret double %cond
|
|
}
|
|
|
|
define i1 @fcmp_oeq_select(i1 %cond, float %a, float %b) {
|
|
; CHECK-LABEL: @fcmp_oeq_select(
|
|
; CHECK-NEXT: [[RES:%.*]] = fcmp oeq float [[A:%.*]], [[B:%.*]]
|
|
; CHECK-NEXT: ret i1 [[RES]]
|
|
;
|
|
%lhs = select i1 %cond, float %a, float %b
|
|
%rhs = select i1 %cond, float %b, float %a
|
|
%res = fcmp oeq float %lhs, %rhs
|
|
ret i1 %res
|
|
}
|
|
|
|
define i1 @fcmp_uno_select(i1 %cond, float %a, float %b) {
|
|
; CHECK-LABEL: @fcmp_uno_select(
|
|
; CHECK-NEXT: [[RES:%.*]] = fcmp uno float [[A:%.*]], [[B:%.*]]
|
|
; CHECK-NEXT: ret i1 [[RES]]
|
|
;
|
|
%lhs = select i1 %cond, float %a, float %b
|
|
%rhs = select i1 %cond, float %b, float %a
|
|
%res = fcmp uno float %lhs, %rhs
|
|
ret i1 %res
|
|
}
|
|
|
|
define i1 @fcmp_ogt_select(i1 %cond, float %a, float %b) {
|
|
; CHECK-LABEL: @fcmp_ogt_select(
|
|
; CHECK-NEXT: [[LHS:%.*]] = select i1 [[COND:%.*]], float [[A:%.*]], float [[B:%.*]]
|
|
; CHECK-NEXT: [[RHS:%.*]] = select i1 [[COND]], float [[B]], float [[A]]
|
|
; CHECK-NEXT: [[RES:%.*]] = fcmp ogt float [[LHS]], [[RHS]]
|
|
; CHECK-NEXT: ret i1 [[RES]]
|
|
;
|
|
%lhs = select i1 %cond, float %a, float %b
|
|
%rhs = select i1 %cond, float %b, float %a
|
|
%res = fcmp ogt float %lhs, %rhs
|
|
ret i1 %res
|
|
}
|
|
|
|
define i1 @test_fcmp_select_const_const(double %x) {
|
|
; CHECK-LABEL: @test_fcmp_select_const_const(
|
|
; CHECK-NEXT: [[CMP1:%.*]] = fcmp uno double [[X:%.*]], 0.000000e+00
|
|
; CHECK-NEXT: ret i1 [[CMP1]]
|
|
;
|
|
%cmp1 = fcmp ord double %x, 0.000000e+00
|
|
%sel = select i1 %cmp1, double 0xFFFFFFFFFFFFFFFF, double 0.000000e+00
|
|
%cmp2 = fcmp oeq double %sel, 0.000000e+00
|
|
ret i1 %cmp2
|
|
}
|
|
|
|
define i1 @test_fcmp_select_var_const(double %x, double %y) {
|
|
; CHECK-LABEL: @test_fcmp_select_var_const(
|
|
; CHECK-NEXT: [[CMP1:%.*]] = fcmp ule double [[X:%.*]], f0x3E80000000000000
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fcmp olt double [[Y:%.*]], f0x3E80000000000000
|
|
; CHECK-NEXT: [[CMP2:%.*]] = select i1 [[CMP1]], i1 true, i1 [[TMP1]]
|
|
; CHECK-NEXT: ret i1 [[CMP2]]
|
|
;
|
|
%cmp1 = fcmp ogt double %x, 0x3E80000000000000
|
|
%sel = select i1 %cmp1, double %y, double 0.000000e+00
|
|
%cmp2 = fcmp olt double %sel, 0x3E80000000000000
|
|
ret i1 %cmp2
|
|
}
|
|
|
|
define i1 @test_fcmp_select_var_const_fmf(double %x, double %y) {
|
|
; CHECK-LABEL: @test_fcmp_select_var_const_fmf(
|
|
; CHECK-NEXT: [[CMP1:%.*]] = fcmp ule double [[X:%.*]], f0x3E80000000000000
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fcmp nnan olt double [[Y:%.*]], f0x3E80000000000000
|
|
; CHECK-NEXT: [[CMP2:%.*]] = select i1 [[CMP1]], i1 true, i1 [[TMP1]]
|
|
; CHECK-NEXT: ret i1 [[CMP2]]
|
|
;
|
|
%cmp1 = fcmp ogt double %x, 0x3E80000000000000
|
|
%sel = select i1 %cmp1, double %y, double 0.000000e+00
|
|
%cmp2 = fcmp nnan olt double %sel, 0x3E80000000000000
|
|
ret i1 %cmp2
|
|
}
|
|
|
|
define <2 x i1> @test_fcmp_select_const_const_vec(<2 x double> %x) {
|
|
; CHECK-LABEL: @test_fcmp_select_const_const_vec(
|
|
; CHECK-NEXT: [[CMP1:%.*]] = fcmp uno <2 x double> [[X:%.*]], zeroinitializer
|
|
; CHECK-NEXT: ret <2 x i1> [[CMP1]]
|
|
;
|
|
%cmp1 = fcmp ord <2 x double> %x, zeroinitializer
|
|
%sel = select <2 x i1> %cmp1, <2 x double> <double 0xFFFFFFFFFFFFFFFF, double 0xFFFFFFFFFFFFFFFF>, <2 x double> zeroinitializer
|
|
%cmp2 = fcmp oeq <2 x double> %sel, zeroinitializer
|
|
ret <2 x i1> %cmp2
|
|
}
|
|
|
|
; Don't break clamp idioms
|
|
|
|
define double @test_fcmp_select_clamp(double %x) {
|
|
; CHECK-LABEL: @test_fcmp_select_clamp(
|
|
; CHECK-NEXT: [[CMP1:%.*]] = fcmp ogt double [[X:%.*]], 9.000000e-01
|
|
; CHECK-NEXT: [[SEL1:%.*]] = select i1 [[CMP1]], double 9.000000e-01, double [[X]]
|
|
; CHECK-NEXT: [[CMP2:%.*]] = fcmp olt double [[SEL1]], 5.000000e-01
|
|
; CHECK-NEXT: [[SEL2:%.*]] = select i1 [[CMP2]], double 5.000000e-01, double [[SEL1]]
|
|
; CHECK-NEXT: ret double [[SEL2]]
|
|
;
|
|
%cmp1 = fcmp ogt double %x, 9.000000e-01
|
|
%sel1 = select i1 %cmp1, double 9.000000e-01, double %x
|
|
%cmp2 = fcmp olt double %sel1, 5.000000e-01
|
|
%sel2 = select i1 %cmp2, double 5.000000e-01, double %sel1
|
|
ret double %sel2
|
|
}
|
|
|
|
; Don't break fmin/fmax idioms
|
|
|
|
define double @test_fcmp_select_maxnum(double %x) {
|
|
; CHECK-LABEL: @test_fcmp_select_maxnum(
|
|
; CHECK-NEXT: [[SEL1:%.*]] = call nnan nsz double @llvm.maxnum.f64(double [[X:%.*]], double 1.000000e+00)
|
|
; CHECK-NEXT: [[SEL2:%.*]] = call nnan nsz double @llvm.minnum.f64(double [[SEL1]], double 2.550000e+02)
|
|
; CHECK-NEXT: ret double [[SEL2]]
|
|
;
|
|
%cmp1 = fcmp nnan ogt double %x, 1.0
|
|
%sel1 = select nsz i1 %cmp1, double %x, double 1.0
|
|
%cmp2 = fcmp nnan olt double %sel1, 255.0
|
|
%sel2 = select nsz i1 %cmp2, double %sel1, double 255.0
|
|
ret double %sel2
|
|
}
|
|
|
|
define i1 @test_fcmp_select_const_const_multiuse(double %x) {
|
|
; CHECK-LABEL: @test_fcmp_select_const_const_multiuse(
|
|
; CHECK-NEXT: [[CMP1:%.*]] = fcmp ord double [[X:%.*]], 0.000000e+00
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP1]], double -nan(0x7FFFFFFFFFFFF), double 0.000000e+00
|
|
; CHECK-NEXT: call void @usef64(double [[SEL]])
|
|
; CHECK-NEXT: [[CMP2:%.*]] = fcmp oeq double [[SEL]], 0.000000e+00
|
|
; CHECK-NEXT: ret i1 [[CMP2]]
|
|
;
|
|
%cmp1 = fcmp ord double %x, 0.000000e+00
|
|
%sel = select i1 %cmp1, double 0xFFFFFFFFFFFFFFFF, double 0.000000e+00
|
|
call void @usef64(double %sel)
|
|
%cmp2 = fcmp oeq double %sel, 0.000000e+00
|
|
ret i1 %cmp2
|
|
}
|
|
|
|
define i1 @test_fcmp_select_const_const_unordered(double %x) {
|
|
; CHECK-LABEL: @test_fcmp_select_const_const_unordered(
|
|
; CHECK-NEXT: [[CMP1:%.*]] = fcmp ord double [[X:%.*]], 0.000000e+00
|
|
; CHECK-NEXT: ret i1 [[CMP1]]
|
|
;
|
|
%cmp1 = fcmp uno double %x, 0.000000e+00
|
|
%sel = select i1 %cmp1, double 0xFFFFFFFFFFFFFFFF, double 0.000000e+00
|
|
%cmp2 = fcmp oeq double %sel, 0.000000e+00
|
|
ret i1 %cmp2
|
|
}
|
|
|
|
define i1 @test_fcmp_select_var_const_unordered(double %x, double %y) {
|
|
; CHECK-LABEL: @test_fcmp_select_var_const_unordered(
|
|
; CHECK-NEXT: [[CMP1:%.*]] = fcmp ult double [[X:%.*]], f0x3E80000000000000
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fcmp ugt double [[Y:%.*]], f0x3E80000000000000
|
|
; CHECK-NEXT: [[CMP2:%.*]] = select i1 [[CMP1]], i1 [[TMP1]], i1 false
|
|
; CHECK-NEXT: ret i1 [[CMP2]]
|
|
;
|
|
%cmp1 = fcmp ult double %x, 0x3E80000000000000
|
|
%sel = select i1 %cmp1, double %y, double 0.000000e+00
|
|
%cmp2 = fcmp ugt double %sel, 0x3E80000000000000
|
|
ret i1 %cmp2
|
|
}
|
|
|
|
define i1 @test_fcmp_ord_select_fcmp_oeq_var_const(double %x) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fcmp_oeq_var_const(
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fcmp oeq double [[X:%.*]], 1.000000e+00
|
|
; CHECK-NEXT: ret i1 [[TMP1]]
|
|
;
|
|
%cmp1 = fcmp ord double %x, 0.000000e+00
|
|
%sel = select i1 %cmp1, double %x, double 0.000000e+00
|
|
%cmp2 = fcmp oeq double %sel, 1.000000e+00
|
|
ret i1 %cmp2
|
|
}
|
|
|
|
define double @test_fcmp_ord_select_fabs_fcmp_one_select_var_const(double %x) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_fcmp_one_select_var_const(
|
|
; CHECK-NEXT: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one double [[ABS]], +inf
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double [[X]], double 0.000000e+00
|
|
; CHECK-NEXT: ret double [[SEL]]
|
|
;
|
|
%cmp1 = fcmp ord double %x, 0.000000e+00
|
|
%sel1 = select i1 %cmp1, double %x, double 0.000000e+00
|
|
%abs = call double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp one double %abs, 0x7FF0000000000000
|
|
%sel2 = select i1 %cmp2, double %sel1, double 0.000000e+00
|
|
ret double %sel2
|
|
}
|
|
|
|
define double @test_fcmp_ord_commuted_select_fabs_fcmp_one_select_var_const(double %x) {
|
|
; CHECK-LABEL: @test_fcmp_ord_commuted_select_fabs_fcmp_one_select_var_const(
|
|
; CHECK-NEXT: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one double [[ABS]], +inf
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double [[X]], double 0.000000e+00
|
|
; CHECK-NEXT: ret double [[SEL]]
|
|
;
|
|
%cmp1 = fcmp ord double 0.000000e+00, %x
|
|
%sel1 = select i1 %cmp1, double %x, double 0.000000e+00
|
|
%abs = call double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp one double %abs, 0x7FF0000000000000
|
|
%sel2 = select i1 %cmp2, double %sel1, double 0.000000e+00
|
|
ret double %sel2
|
|
}
|
|
|
|
define double @test_fcmp_ord_select_fabs_fcmp_one_select_nonnan_const(double %x, double %y) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_fcmp_one_select_nonnan_const(
|
|
; CHECK-NEXT: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one double [[ABS]], +inf
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double [[X]], double [[Y:%.*]]
|
|
; CHECK-NEXT: ret double [[SEL]]
|
|
;
|
|
%cmp1 = fcmp ord double %x, 1.000000e+00
|
|
%sel1 = select i1 %cmp1, double %x, double %y
|
|
%abs = call double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp one double %abs, 0x7FF0000000000000
|
|
%sel2 = select i1 %cmp2, double %sel1, double %y
|
|
ret double %sel2
|
|
}
|
|
|
|
define double @test_fcmp_ord_self_select_fabs_fcmp_one_select_var_var(double %x, double %y) {
|
|
; CHECK-LABEL: @test_fcmp_ord_self_select_fabs_fcmp_one_select_var_var(
|
|
; CHECK-NEXT: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one double [[ABS]], +inf
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double [[X]], double [[Y:%.*]]
|
|
; CHECK-NEXT: ret double [[SEL]]
|
|
;
|
|
%cmp1 = fcmp ord double %x, %x
|
|
%sel1 = select i1 %cmp1, double %x, double %y
|
|
%abs = call double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp one double %abs, 0x7FF0000000000000
|
|
%sel2 = select i1 %cmp2, double %sel1, double %y
|
|
ret double %sel2
|
|
}
|
|
|
|
define double @test_fcmp_ord_select_fabs_fcmp_one_select_uitofp_nonnan(double %x, double %y, i32 %i) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_fcmp_one_select_uitofp_nonnan(
|
|
; CHECK: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one double [[ABS]], +inf
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double [[X]], double [[Y:%.*]]
|
|
; CHECK-NEXT: ret double [[SEL]]
|
|
;
|
|
%nonnan = uitofp i32 %i to double
|
|
%cmp1 = fcmp ord double %x, %nonnan
|
|
%sel1 = select i1 %cmp1, double %x, double %y
|
|
%abs = call double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp one double %abs, 0x7FF0000000000000
|
|
%sel2 = select i1 %cmp2, double %sel1, double %y
|
|
ret double %sel2
|
|
}
|
|
|
|
define double @test_fcmp_ord_commuted_select_fabs_fcmp_one_select_sitofp_nonnan(double %x, double %y, i32 %i) {
|
|
; CHECK-LABEL: @test_fcmp_ord_commuted_select_fabs_fcmp_one_select_sitofp_nonnan(
|
|
; CHECK: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one double [[ABS]], +inf
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double [[X]], double [[Y:%.*]]
|
|
; CHECK-NEXT: ret double [[SEL]]
|
|
;
|
|
%nonnan = sitofp i32 %i to double
|
|
%cmp1 = fcmp ord double %nonnan, %x
|
|
%sel1 = select i1 %cmp1, double %x, double %y
|
|
%abs = call double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp one double %abs, 0x7FF0000000000000
|
|
%sel2 = select i1 %cmp2, double %sel1, double %y
|
|
ret double %sel2
|
|
}
|
|
|
|
define double @test_fcmp_ord_select_fabs_rhs_fcmp_ogt_select_uitofp_nonnan(double %x, double %y, double %k, i32 %i) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_rhs_fcmp_ogt_select_uitofp_nonnan(
|
|
; CHECK: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp olt double [[ABS]], [[K:%.*]]
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double [[X]], double [[Y:%.*]]
|
|
; CHECK-NEXT: ret double [[SEL]]
|
|
;
|
|
%nonnan = uitofp i32 %i to double
|
|
%cmp1 = fcmp ord double %x, %nonnan
|
|
%sel1 = select i1 %cmp1, double %x, double %y
|
|
%abs = call double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp ogt double %k, %abs
|
|
%sel2 = select i1 %cmp2, double %sel1, double %y
|
|
ret double %sel2
|
|
}
|
|
|
|
define double @test_fcmp_ord_select_fabs_fcmp_une_select_var_const(double %x) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_fcmp_une_select_var_const(
|
|
; CHECK-NEXT: [[CMP1:%.*]] = fcmp ord double [[X:%.*]], 0.000000e+00
|
|
; CHECK-NEXT: [[SEL1:%.*]] = select i1 [[CMP1]], double [[X]], double 0.000000e+00
|
|
; CHECK-NEXT: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[SEL1]])
|
|
; CHECK-NEXT: [[CMP2:%.*]] = fcmp une double [[ABS]], +inf
|
|
; CHECK-NEXT: [[SEL2:%.*]] = select i1 [[CMP2]], double [[SEL1]], double 0.000000e+00
|
|
; CHECK-NEXT: ret double [[SEL2]]
|
|
;
|
|
%cmp1 = fcmp ord double %x, 0.000000e+00
|
|
%sel1 = select i1 %cmp1, double %x, double 0.000000e+00
|
|
%abs = call double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp une double %abs, 0x7FF0000000000000
|
|
%sel2 = select i1 %cmp2, double %sel1, double 0.000000e+00
|
|
ret double %sel2
|
|
}
|
|
|
|
define double @test_fcmp_ord_select_fabs_fcmp_nnan_one_select_var_var(double %x, double %y) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_fcmp_nnan_one_select_var_var(
|
|
; CHECK-NEXT: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one double [[ABS]], +inf
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double [[X]], double [[Y:%.*]]
|
|
; CHECK-NEXT: ret double [[SEL]]
|
|
;
|
|
%cmp1 = fcmp ord double %x, 0.000000e+00
|
|
%sel1 = select i1 %cmp1, double %x, double %y
|
|
%abs = call double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp nnan one double %abs, 0x7FF0000000000000
|
|
%sel2 = select i1 %cmp2, double %sel1, double %y
|
|
ret double %sel2
|
|
}
|
|
|
|
define double @test_fcmp_ord_select_fabs_rhs_fcmp_ogt_select_var_var(double %x, double %y, double %k) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_rhs_fcmp_ogt_select_var_var(
|
|
; CHECK-NEXT: [[ABS:%.*]] = call ninf double @llvm.fabs.f64(double [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf olt double [[ABS]], [[K:%.*]]
|
|
; CHECK-NEXT: [[SEL:%.*]] = select nnan i1 [[CMP]], double [[X]], double [[Y:%.*]]
|
|
; CHECK-NEXT: ret double [[SEL]]
|
|
;
|
|
%cmp1 = fcmp ord double %x, 0.000000e+00
|
|
%sel1 = select i1 %cmp1, double %x, double %y
|
|
%abs = call ninf double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp ninf ogt double %k, %abs
|
|
%sel2 = select nnan i1 %cmp2, double %sel1, double %y
|
|
ret double %sel2
|
|
}
|
|
|
|
define <2 x double> @test_fcmp_ord_select_fabs_fcmp_one_select_v2f64(<2 x double> %x, <2 x double> %y) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_fcmp_one_select_v2f64(
|
|
; CHECK-NEXT: [[ABS:%.*]] = call <2 x double> @llvm.fabs.v2f64(<2 x double> [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one <2 x double> [[ABS]], splat (double +inf)
|
|
; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> [[CMP]], <2 x double> [[X]], <2 x double> [[Y:%.*]]
|
|
; CHECK-NEXT: ret <2 x double> [[SEL]]
|
|
;
|
|
%cmp1 = fcmp ord <2 x double> %x, zeroinitializer
|
|
%sel1 = select <2 x i1> %cmp1, <2 x double> %x, <2 x double> %y
|
|
%abs = call <2 x double> @llvm.fabs.v2f64(<2 x double> %sel1)
|
|
%cmp2 = fcmp one <2 x double> %abs, <double 0x7FF0000000000000, double 0x7FF0000000000000>
|
|
%sel2 = select <2 x i1> %cmp2, <2 x double> %sel1, <2 x double> %y
|
|
ret <2 x double> %sel2
|
|
}
|
|
|
|
define <2 x double> @test_fcmp_ord_select_fabs_fcmp_one_select_uitofp_v2f64(<2 x double> %x, <2 x double> %y, <2 x i32> %i) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_fcmp_one_select_uitofp_v2f64(
|
|
; CHECK: [[ABS:%.*]] = call <2 x double> @llvm.fabs.v2f64(<2 x double> [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one <2 x double> [[ABS]], splat (double +inf)
|
|
; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> [[CMP]], <2 x double> [[X]], <2 x double> [[Y:%.*]]
|
|
; CHECK-NEXT: ret <2 x double> [[SEL]]
|
|
;
|
|
%nonnan = uitofp <2 x i32> %i to <2 x double>
|
|
%cmp1 = fcmp ord <2 x double> %x, %nonnan
|
|
%sel1 = select <2 x i1> %cmp1, <2 x double> %x, <2 x double> %y
|
|
%abs = call <2 x double> @llvm.fabs.v2f64(<2 x double> %sel1)
|
|
%cmp2 = fcmp one <2 x double> %abs, <double 0x7FF0000000000000, double 0x7FF0000000000000>
|
|
%sel2 = select <2 x i1> %cmp2, <2 x double> %sel1, <2 x double> %y
|
|
ret <2 x double> %sel2
|
|
}
|
|
|
|
define <2 x double> @test_fcmp_ord_select_fabs_fcmp_nnan_one_select_v2f64(<2 x double> %x, <2 x double> %y) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_fcmp_nnan_one_select_v2f64(
|
|
; CHECK-NEXT: [[ABS:%.*]] = call <2 x double> @llvm.fabs.v2f64(<2 x double> [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one <2 x double> [[ABS]], splat (double +inf)
|
|
; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> [[CMP]], <2 x double> [[X]], <2 x double> [[Y:%.*]]
|
|
; CHECK-NEXT: ret <2 x double> [[SEL]]
|
|
;
|
|
%cmp1 = fcmp ord <2 x double> %x, zeroinitializer
|
|
%sel1 = select <2 x i1> %cmp1, <2 x double> %x, <2 x double> %y
|
|
%abs = call <2 x double> @llvm.fabs.v2f64(<2 x double> %sel1)
|
|
%cmp2 = fcmp nnan one <2 x double> %abs, <double 0x7FF0000000000000, double 0x7FF0000000000000>
|
|
%sel2 = select <2 x i1> %cmp2, <2 x double> %sel1, <2 x double> %y
|
|
ret <2 x double> %sel2
|
|
}
|
|
|
|
define double @test_fcmp_ord_select_fabs_fcmp_fabs_only_ninf(double %x, double %y, double %k) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_fcmp_fabs_only_ninf(
|
|
; CHECK-NEXT: [[ABS:%.*]] = call ninf double @llvm.fabs.f64(double [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp one double [[ABS]], [[K:%.*]]
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double [[X]], double [[Y:%.*]]
|
|
; CHECK-NEXT: ret double [[SEL]]
|
|
;
|
|
%cmp1 = fcmp ord double %x, 0.000000e+00
|
|
%sel1 = select i1 %cmp1, double %x, double %y
|
|
%abs = call ninf double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp one double %abs, %k
|
|
%sel2 = select i1 %cmp2, double %sel1, double %y
|
|
ret double %sel2
|
|
}
|
|
|
|
define double @test_fcmp_ord_select_fabs_fcmp_cmp_only_ninf(double %x, double %y, double %k) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_fcmp_cmp_only_ninf(
|
|
; CHECK-NEXT: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf one double [[ABS]], [[K:%.*]]
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double [[X]], double [[Y:%.*]]
|
|
; CHECK-NEXT: ret double [[SEL]]
|
|
;
|
|
%cmp1 = fcmp ord double %x, 0.000000e+00
|
|
%sel1 = select i1 %cmp1, double %x, double %y
|
|
%abs = call double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp ninf one double %abs, %k
|
|
%sel2 = select i1 %cmp2, double %sel1, double %y
|
|
ret double %sel2
|
|
}
|
|
|
|
define double @test_fcmp_ord_select_fabs_fcmp_intersect_drop_nnan(double %x, double %y, double %k) {
|
|
; CHECK-LABEL: @test_fcmp_ord_select_fabs_fcmp_intersect_drop_nnan(
|
|
; CHECK-NEXT: [[ABS:%.*]] = call ninf double @llvm.fabs.f64(double [[X:%.*]])
|
|
; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf one double [[ABS]], [[K:%.*]]
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double [[X]], double [[Y:%.*]]
|
|
; CHECK-NEXT: ret double [[SEL]]
|
|
;
|
|
%cmp1 = fcmp ord double %x, 0.000000e+00
|
|
%sel1 = select i1 %cmp1, double %x, double %y
|
|
%abs = call nnan ninf double @llvm.fabs.f64(double %sel1)
|
|
%cmp2 = fcmp nnan ninf one double %abs, %k
|
|
%sel2 = select i1 %cmp2, double %sel1, double %y
|
|
ret double %sel2
|
|
}
|
|
|
|
; Make sure that we recognize the SPF correctly.
|
|
|
|
define float @test_select_nnan_nsz_fcmp_olt(float %x) {
|
|
; CHECK-LABEL: @test_select_nnan_nsz_fcmp_olt(
|
|
; CHECK-NEXT: [[TMP1:%.*]] = fcmp olt float [[X:%.*]], -0.000000e+00
|
|
; CHECK-NEXT: [[SEL1:%.*]] = select i1 [[TMP1]], float [[X]], float -0.000000e+00
|
|
; CHECK-NEXT: ret float [[SEL1]]
|
|
;
|
|
%cmp = fcmp olt float %x, 0.000000e+00
|
|
%sel = select nnan nsz i1 %cmp, float %x, float -0.000000e+00
|
|
ret float %sel
|
|
}
|
|
|
|
define float @test_select_nnan_nsz_fcmp_ult(float %x) {
|
|
; CHECK-LABEL: @test_select_nnan_nsz_fcmp_ult(
|
|
; CHECK-NEXT: [[DOTINV:%.*]] = fcmp oge float [[X:%.*]], 0.000000e+00
|
|
; CHECK-NEXT: [[SEL1:%.*]] = select i1 [[DOTINV]], float -0.000000e+00, float [[X]]
|
|
; CHECK-NEXT: ret float [[SEL1]]
|
|
;
|
|
%cmp = fcmp ult float %x, 0.000000e+00
|
|
%sel = select nnan nsz i1 %cmp, float %x, float -0.000000e+00
|
|
ret float %sel
|
|
}
|
|
|
|
define float @test_select_fcmp_sitofp_max(i8 %x) {
|
|
; CHECK-LABEL: @test_select_fcmp_sitofp_max(
|
|
; CHECK-NEXT: [[F:%.*]] = sitofp i8 [[X:%.*]] to float
|
|
; CHECK-NEXT: ret float [[F]]
|
|
;
|
|
%f = sitofp i8 %x to float
|
|
%cmp = fcmp ole float %f, -1.280000e+02
|
|
%sel = select i1 %cmp, float -1.280000e+02, float %f
|
|
ret float %sel
|
|
}
|
|
|
|
define <2 x float> @test_select_fcmp_sitofp_max_vec(<2 x i8> %x) {
|
|
; CHECK-LABEL: @test_select_fcmp_sitofp_max_vec(
|
|
; CHECK-NEXT: [[F:%.*]] = sitofp <2 x i8> [[X:%.*]] to <2 x float>
|
|
; CHECK-NEXT: ret <2 x float> [[F]]
|
|
;
|
|
%f = sitofp <2 x i8> %x to <2 x float>
|
|
%cmp = fcmp ole <2 x float> %f, splat (float -1.280000e+02)
|
|
%sel = select <2 x i1> %cmp, <2 x float> splat (float -1.280000e+02), <2 x float> %f
|
|
ret <2 x float> %sel
|
|
}
|
|
|
|
define float @test_select_fcmp_sitofp_min(i8 %x) {
|
|
; CHECK-LABEL: @test_select_fcmp_sitofp_min(
|
|
; CHECK-NEXT: [[F:%.*]] = sitofp i8 [[X:%.*]] to float
|
|
; CHECK-NEXT: ret float [[F]]
|
|
;
|
|
%f = sitofp i8 %x to float
|
|
%cmp = fcmp oge float %f, 1.270000e+02
|
|
%sel = select i1 %cmp, float 1.270000e+02, float %f
|
|
ret float %sel
|
|
}
|
|
|
|
define float @test_select_fcmp_uitofp_min(i8 %x) {
|
|
; CHECK-LABEL: @test_select_fcmp_uitofp_min(
|
|
; CHECK-NEXT: [[F:%.*]] = uitofp i8 [[X:%.*]] to float
|
|
; CHECK-NEXT: ret float [[F]]
|
|
;
|
|
%f = uitofp i8 %x to float
|
|
%cmp = fcmp oge float %f, 2.550000e+02
|
|
%sel = select i1 %cmp, float 2.550000e+02, float %f
|
|
ret float %sel
|
|
}
|