2016-06-06 01:29:45 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
2010-02-22 12:06:03 +08:00
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
|
|
|
2017-09-02 22:35:18 +08:00
|
|
|
define i1 @oeq_self(double %arg) {
|
|
|
|
; CHECK-LABEL: @oeq_self(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[TMP:%.*]] = fcmp ord double [[ARG:%.*]], 0.000000e+00
|
2016-06-06 01:29:45 +08:00
|
|
|
; CHECK-NEXT: ret i1 [[TMP]]
|
|
|
|
;
|
2010-02-22 12:06:03 +08:00
|
|
|
%tmp = fcmp oeq double %arg, %arg
|
|
|
|
ret i1 %tmp
|
|
|
|
}
|
|
|
|
|
2017-09-02 22:35:18 +08:00
|
|
|
; PR1111 - https://bugs.llvm.org/show_bug.cgi?id=1111
|
|
|
|
|
|
|
|
define i1 @une_self(double %x) {
|
|
|
|
; CHECK-LABEL: @une_self(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[TMP:%.*]] = fcmp uno double [[X:%.*]], 0.000000e+00
|
2017-09-02 22:35:18 +08:00
|
|
|
; CHECK-NEXT: ret i1 [[TMP]]
|
|
|
|
;
|
|
|
|
%tmp = fcmp une double %x, %x
|
|
|
|
ret i1 %tmp
|
|
|
|
}
|
|
|
|
|
2017-09-03 23:35:10 +08:00
|
|
|
; When just checking for a NaN (ORD/UNO), canonicalize constants.
|
|
|
|
; Float/double are alternated for additional coverage.
|
|
|
|
|
|
|
|
define i1 @ord_zero(float %x) {
|
|
|
|
; CHECK-LABEL: @ord_zero(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp ord float [[X:%.*]], 0.000000e+00
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret i1 [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp ord float %x, 0.0
|
|
|
|
ret i1 %f
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @ord_nonzero(double %x) {
|
|
|
|
; CHECK-LABEL: @ord_nonzero(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp ord double [[X:%.*]], 0.000000e+00
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret i1 [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp ord double %x, 3.0
|
|
|
|
ret i1 %f
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @ord_self(float %x) {
|
|
|
|
; CHECK-LABEL: @ord_self(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp ord float [[X:%.*]], 0.000000e+00
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret i1 [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp ord float %x, %x
|
|
|
|
ret i1 %f
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @uno_zero(double %x) {
|
|
|
|
; CHECK-LABEL: @uno_zero(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp uno double [[X:%.*]], 0.000000e+00
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret i1 [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp uno double %x, 0.0
|
|
|
|
ret i1 %f
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @uno_nonzero(float %x) {
|
|
|
|
; CHECK-LABEL: @uno_nonzero(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp uno float [[X:%.*]], 0.000000e+00
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret i1 [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp uno float %x, 3.0
|
|
|
|
ret i1 %f
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @uno_self(double %x) {
|
|
|
|
; CHECK-LABEL: @uno_self(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp uno double [[X:%.*]], 0.000000e+00
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret i1 [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp uno double %x, %x
|
|
|
|
ret i1 %f
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i1> @ord_zero_vec(<2 x double> %x) {
|
|
|
|
; CHECK-LABEL: @ord_zero_vec(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp ord <2 x double> [[X:%.*]], zeroinitializer
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i1> [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp ord <2 x double> %x, zeroinitializer
|
|
|
|
ret <2 x i1> %f
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i1> @ord_nonzero_vec(<2 x float> %x) {
|
|
|
|
; CHECK-LABEL: @ord_nonzero_vec(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp ord <2 x float> [[X:%.*]], zeroinitializer
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i1> [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp ord <2 x float> %x, <float 3.0, float 5.0>
|
|
|
|
ret <2 x i1> %f
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i1> @ord_self_vec(<2 x double> %x) {
|
|
|
|
; CHECK-LABEL: @ord_self_vec(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp ord <2 x double> [[X:%.*]], zeroinitializer
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i1> [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp ord <2 x double> %x, %x
|
|
|
|
ret <2 x i1> %f
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i1> @uno_zero_vec(<2 x float> %x) {
|
|
|
|
; CHECK-LABEL: @uno_zero_vec(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp uno <2 x float> [[X:%.*]], zeroinitializer
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i1> [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp uno <2 x float> %x, zeroinitializer
|
|
|
|
ret <2 x i1> %f
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i1> @uno_nonzero_vec(<2 x double> %x) {
|
|
|
|
; CHECK-LABEL: @uno_nonzero_vec(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp uno <2 x double> [[X:%.*]], zeroinitializer
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i1> [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp uno <2 x double> %x, <double 3.0, double 5.0>
|
|
|
|
ret <2 x i1> %f
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i1> @uno_self_vec(<2 x float> %x) {
|
|
|
|
; CHECK-LABEL: @uno_self_vec(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp uno <2 x float> [[X:%.*]], zeroinitializer
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i1> [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp uno <2 x float> %x, %x
|
|
|
|
ret <2 x i1> %f
|
|
|
|
}
|
|
|
|
|
|
|
|
; If a scalar constant is NaN in any of the above tests, it would have been eliminated by InstSimplify.
|
|
|
|
; If a vector has a NaN element, we don't do anything with it.
|
|
|
|
|
|
|
|
define <2 x i1> @uno_vec_with_nan(<2 x double> %x) {
|
|
|
|
; CHECK-LABEL: @uno_vec_with_nan(
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp uno <2 x double> [[X:%.*]], <double 3.000000e+00, double 0x7FF00000FFFFFFFF>
|
2017-09-03 23:35:10 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i1> [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp uno <2 x double> %x, <double 3.0, double 0x7FF00000FFFFFFFF>
|
|
|
|
ret <2 x i1> %f
|
|
|
|
}
|
|
|
|
|
2018-03-26 01:48:20 +08:00
|
|
|
define <2 x i1> @uno_vec_with_undef(<2 x double> %x) {
|
|
|
|
; CHECK-LABEL: @uno_vec_with_undef(
|
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp uno <2 x double> [[X:%.*]], zeroinitializer
|
|
|
|
; CHECK-NEXT: ret <2 x i1> [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp uno <2 x double> %x, <double 3.0, double undef>
|
|
|
|
ret <2 x i1> %f
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i1> @ord_vec_with_undef(<2 x double> %x) {
|
|
|
|
; CHECK-LABEL: @ord_vec_with_undef(
|
2018-03-26 05:16:33 +08:00
|
|
|
; CHECK-NEXT: [[F:%.*]] = fcmp ord <2 x double> [[X:%.*]], <double 0.000000e+00, double undef>
|
2018-03-26 01:48:20 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i1> [[F]]
|
|
|
|
;
|
|
|
|
%f = fcmp ord <2 x double> %x, <double 0.0, double undef>
|
|
|
|
ret <2 x i1> %f
|
|
|
|
}
|
2017-09-06 05:20:35 +08:00
|
|
|
; TODO: This could be handled in InstSimplify.
|
|
|
|
|
|
|
|
define i1 @nnan_ops_to_fcmp_ord(float %x, float %y) {
|
|
|
|
; CHECK-LABEL: @nnan_ops_to_fcmp_ord(
|
2017-09-06 07:13:13 +08:00
|
|
|
; CHECK-NEXT: ret i1 true
|
2017-09-06 05:20:35 +08:00
|
|
|
;
|
|
|
|
%mul = fmul nnan float %x, %y
|
|
|
|
%div = fdiv nnan float %x, %y
|
|
|
|
%cmp = fcmp ord float %mul, %div
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; TODO: This could be handled in InstSimplify.
|
|
|
|
|
|
|
|
define i1 @nnan_ops_to_fcmp_uno(float %x, float %y) {
|
|
|
|
; CHECK-LABEL: @nnan_ops_to_fcmp_uno(
|
2017-09-06 07:13:13 +08:00
|
|
|
; CHECK-NEXT: ret i1 false
|
2017-09-06 05:20:35 +08:00
|
|
|
;
|
|
|
|
%mul = fmul nnan float %x, %y
|
|
|
|
%div = fdiv nnan float %x, %y
|
|
|
|
%cmp = fcmp uno float %mul, %div
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|