mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[InstCombine] Fix PR47960 - Incorrect transformation of fabs with nnan flag
Bug Fix for PR: https://llvm.org/PR47960 This patch makes sure that the fast math flag used in the 'select' instruction is the same as the 'fabs' instruction after the transformation. Differential Revision: https://reviews.llvm.org/D101727
This commit is contained in:
parent
5c9c7cf653
commit
6d0cc981cb
@ -2866,15 +2866,13 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
|
||||
// fast-math-flags (nsz) or fsub with +0.0 (not fneg) for this to work. We
|
||||
// also require nnan because we do not want to unintentionally change the
|
||||
// sign of a NaN value.
|
||||
// FIXME: These folds should test/propagate FMF from the select, not the
|
||||
// fsub or fneg.
|
||||
// (X <= +/-0.0) ? (0.0 - X) : X --> fabs(X)
|
||||
Instruction *FSub;
|
||||
if (match(CondVal, m_FCmp(Pred, m_Specific(FalseVal), m_AnyZeroFP())) &&
|
||||
match(TrueVal, m_FSub(m_PosZeroFP(), m_Specific(FalseVal))) &&
|
||||
match(TrueVal, m_Instruction(FSub)) && FSub->hasNoNaNs() &&
|
||||
(Pred == FCmpInst::FCMP_OLE || Pred == FCmpInst::FCMP_ULE)) {
|
||||
Value *Fabs = Builder.CreateUnaryIntrinsic(Intrinsic::fabs, FalseVal, FSub);
|
||||
Value *Fabs = Builder.CreateUnaryIntrinsic(Intrinsic::fabs, FalseVal, &SI);
|
||||
return replaceInstUsesWith(SI, Fabs);
|
||||
}
|
||||
// (X > +/-0.0) ? X : (0.0 - X) --> fabs(X)
|
||||
@ -2882,7 +2880,7 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
|
||||
match(FalseVal, m_FSub(m_PosZeroFP(), m_Specific(TrueVal))) &&
|
||||
match(FalseVal, m_Instruction(FSub)) && FSub->hasNoNaNs() &&
|
||||
(Pred == FCmpInst::FCMP_OGT || Pred == FCmpInst::FCMP_UGT)) {
|
||||
Value *Fabs = Builder.CreateUnaryIntrinsic(Intrinsic::fabs, TrueVal, FSub);
|
||||
Value *Fabs = Builder.CreateUnaryIntrinsic(Intrinsic::fabs, TrueVal, &SI);
|
||||
return replaceInstUsesWith(SI, Fabs);
|
||||
}
|
||||
// With nnan and nsz:
|
||||
@ -2891,11 +2889,11 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
|
||||
Instruction *FNeg;
|
||||
if (match(CondVal, m_FCmp(Pred, m_Specific(FalseVal), m_AnyZeroFP())) &&
|
||||
match(TrueVal, m_FNeg(m_Specific(FalseVal))) &&
|
||||
match(TrueVal, m_Instruction(FNeg)) &&
|
||||
FNeg->hasNoNaNs() && FNeg->hasNoSignedZeros() &&
|
||||
match(TrueVal, m_Instruction(FNeg)) && FNeg->hasNoNaNs() &&
|
||||
FNeg->hasNoSignedZeros() && SI.hasNoSignedZeros() &&
|
||||
(Pred == FCmpInst::FCMP_OLT || Pred == FCmpInst::FCMP_OLE ||
|
||||
Pred == FCmpInst::FCMP_ULT || Pred == FCmpInst::FCMP_ULE)) {
|
||||
Value *Fabs = Builder.CreateUnaryIntrinsic(Intrinsic::fabs, FalseVal, FNeg);
|
||||
Value *Fabs = Builder.CreateUnaryIntrinsic(Intrinsic::fabs, FalseVal, &SI);
|
||||
return replaceInstUsesWith(SI, Fabs);
|
||||
}
|
||||
// With nnan and nsz:
|
||||
@ -2903,11 +2901,11 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
|
||||
// (X >= +/-0.0) ? X : -X --> fabs(X)
|
||||
if (match(CondVal, m_FCmp(Pred, m_Specific(TrueVal), m_AnyZeroFP())) &&
|
||||
match(FalseVal, m_FNeg(m_Specific(TrueVal))) &&
|
||||
match(FalseVal, m_Instruction(FNeg)) &&
|
||||
FNeg->hasNoNaNs() && FNeg->hasNoSignedZeros() &&
|
||||
match(FalseVal, m_Instruction(FNeg)) && FNeg->hasNoNaNs() &&
|
||||
FNeg->hasNoSignedZeros() && SI.hasNoSignedZeros() &&
|
||||
(Pred == FCmpInst::FCMP_OGT || Pred == FCmpInst::FCMP_OGE ||
|
||||
Pred == FCmpInst::FCMP_UGT || Pred == FCmpInst::FCMP_UGE)) {
|
||||
Value *Fabs = Builder.CreateUnaryIntrinsic(Intrinsic::fabs, TrueVal, FNeg);
|
||||
Value *Fabs = Builder.CreateUnaryIntrinsic(Intrinsic::fabs, TrueVal, &SI);
|
||||
return replaceInstUsesWith(SI, Fabs);
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ define double @select_fcmp_ole_zero(double %x) {
|
||||
|
||||
define double @select_fcmp_nnan_ole_zero(double %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_ole_zero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: ret double [[TMP1]]
|
||||
;
|
||||
%lezero = fcmp ole double %x, 0.0
|
||||
@ -293,7 +293,7 @@ define double @select_nnan_fcmp_nnan_ole_zero(double %x) {
|
||||
|
||||
define double @select_fcmp_nnan_ule_zero(double %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_ule_zero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: ret double [[TMP1]]
|
||||
;
|
||||
%lezero = fcmp ule double %x, 0.0
|
||||
@ -321,7 +321,7 @@ define double @select_fcmp_nnan_olt_zero(double %x) {
|
||||
|
||||
define <2 x float> @select_fcmp_nnan_ole_negzero(<2 x float> %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_ole_negzero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan <2 x float> @llvm.fabs.v2f32(<2 x float> [[X:%.*]])
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[X:%.*]])
|
||||
; CHECK-NEXT: ret <2 x float> [[TMP1]]
|
||||
;
|
||||
%lezero = fcmp ole <2 x float> %x, <float -0.0, float -0.0>
|
||||
@ -345,7 +345,7 @@ define <2 x float> @select_nnan_fcmp_nnan_ole_negzero(<2 x float> %x) {
|
||||
|
||||
define fp128 @select_fcmp_nnan_ogt_zero(fp128 %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_ogt_zero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan fp128 @llvm.fabs.f128(fp128 [[X:%.*]])
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call fp128 @llvm.fabs.f128(fp128 [[X:%.*]])
|
||||
; CHECK-NEXT: ret fp128 [[TMP1]]
|
||||
;
|
||||
%gtzero = fcmp ogt fp128 %x, zeroinitializer
|
||||
@ -369,7 +369,7 @@ define fp128 @select_nnan_fcmp_nnan_ogt_zero(fp128 %x) {
|
||||
|
||||
define half @select_fcmp_nnan_ogt_negzero(half %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_ogt_negzero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan half @llvm.fabs.f16(half [[X:%.*]])
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call half @llvm.fabs.f16(half [[X:%.*]])
|
||||
; CHECK-NEXT: ret half [[TMP1]]
|
||||
;
|
||||
%gtzero = fcmp ogt half %x, -0.0
|
||||
@ -393,7 +393,7 @@ define half @select_nnan_fcmp_nnan_ogt_negzero(half %x) {
|
||||
|
||||
define half @select_fcmp_nnan_ugt_negzero(half %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_ugt_negzero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan half @llvm.fabs.f16(half [[X:%.*]])
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call half @llvm.fabs.f16(half [[X:%.*]])
|
||||
; CHECK-NEXT: ret half [[TMP1]]
|
||||
;
|
||||
%gtzero = fcmp ugt half %x, -0.0
|
||||
@ -421,8 +421,10 @@ define half @select_fcmp_nnan_oge_negzero(half %x) {
|
||||
|
||||
define double @select_fcmp_nnan_nsz_olt_zero(double %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_olt_zero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: ret double [[TMP1]]
|
||||
; CHECK-NEXT: [[LTZERO:%.*]] = fcmp olt double [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz double [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LTZERO]], double [[NEGX]], double [[X]]
|
||||
; CHECK-NEXT: ret double [[FABS]]
|
||||
;
|
||||
%ltzero = fcmp olt double %x, 0.0
|
||||
%negx = fsub nnan nsz double -0.0, %x
|
||||
@ -445,8 +447,10 @@ define double @select_nnan_nsz_fcmp_nnan_nsz_olt_zero(double %x) {
|
||||
|
||||
define double @select_fcmp_nnan_nsz_ult_zero(double %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ult_zero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: ret double [[TMP1]]
|
||||
; CHECK-NEXT: [[LTZERO:%.*]] = fcmp ult double [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz double [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LTZERO]], double [[NEGX]], double [[X]]
|
||||
; CHECK-NEXT: ret double [[FABS]]
|
||||
;
|
||||
%ltzero = fcmp ult double %x, 0.0
|
||||
%negx = fsub nnan nsz double -0.0, %x
|
||||
@ -456,8 +460,10 @@ define double @select_fcmp_nnan_nsz_ult_zero(double %x) {
|
||||
|
||||
define double @select_fcmp_nnan_nsz_olt_zero_unary_fneg(double %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_olt_zero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: ret double [[TMP1]]
|
||||
; CHECK-NEXT: [[LTZERO:%.*]] = fcmp olt double [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz double [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LTZERO]], double [[NEGX]], double [[X]]
|
||||
; CHECK-NEXT: ret double [[FABS]]
|
||||
;
|
||||
%ltzero = fcmp olt double %x, 0.0
|
||||
%negx = fneg nnan nsz double %x
|
||||
@ -469,8 +475,10 @@ define double @select_fcmp_nnan_nsz_olt_zero_unary_fneg(double %x) {
|
||||
|
||||
define double @select_fcmp_nnan_nsz_ult_zero_unary_fneg(double %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ult_zero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: ret double [[TMP1]]
|
||||
; CHECK-NEXT: [[LTZERO:%.*]] = fcmp ult double [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz double [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LTZERO]], double [[NEGX]], double [[X]]
|
||||
; CHECK-NEXT: ret double [[FABS]]
|
||||
;
|
||||
%ltzero = fcmp ult double %x, 0.0
|
||||
%negx = fneg nnan nsz double %x
|
||||
@ -482,8 +490,10 @@ define double @select_fcmp_nnan_nsz_ult_zero_unary_fneg(double %x) {
|
||||
|
||||
define float @select_fcmp_nnan_nsz_olt_negzero(float %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_olt_negzero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf nsz float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: ret float [[TMP1]]
|
||||
; CHECK-NEXT: [[LTZERO:%.*]] = fcmp olt float [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan ninf nsz float [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LTZERO]], float [[NEGX]], float [[X]]
|
||||
; CHECK-NEXT: ret float [[FABS]]
|
||||
;
|
||||
%ltzero = fcmp olt float %x, -0.0
|
||||
%negx = fsub nnan ninf nsz float -0.0, %x
|
||||
@ -493,7 +503,7 @@ define float @select_fcmp_nnan_nsz_olt_negzero(float %x) {
|
||||
|
||||
define float @select_nnan_ninf_nsz_fcmp_nnan_nsz_olt_negzero(float %x) {
|
||||
; CHECK-LABEL: @select_nnan_ninf_nsz_fcmp_nnan_nsz_olt_negzero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf nsz float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: ret float [[TMP1]]
|
||||
;
|
||||
%ltzero = fcmp olt float %x, -0.0
|
||||
@ -506,8 +516,10 @@ define float @select_nnan_ninf_nsz_fcmp_nnan_nsz_olt_negzero(float %x) {
|
||||
|
||||
define float @select_fcmp_nnan_nsz_ult_negzero(float %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ult_negzero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf nsz float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: ret float [[TMP1]]
|
||||
; CHECK-NEXT: [[LTZERO:%.*]] = fcmp ult float [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan ninf nsz float [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LTZERO]], float [[NEGX]], float [[X]]
|
||||
; CHECK-NEXT: ret float [[FABS]]
|
||||
;
|
||||
%ltzero = fcmp ult float %x, -0.0
|
||||
%negx = fsub nnan ninf nsz float -0.0, %x
|
||||
@ -517,8 +529,10 @@ define float @select_fcmp_nnan_nsz_ult_negzero(float %x) {
|
||||
|
||||
define float @select_fcmp_nnan_nsz_olt_negzero_unary_fneg(float %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_olt_negzero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf nsz float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: ret float [[TMP1]]
|
||||
; CHECK-NEXT: [[LTZERO:%.*]] = fcmp olt float [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan ninf nsz float [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LTZERO]], float [[NEGX]], float [[X]]
|
||||
; CHECK-NEXT: ret float [[FABS]]
|
||||
;
|
||||
%ltzero = fcmp olt float %x, -0.0
|
||||
%negx = fneg nnan ninf nsz float %x
|
||||
@ -530,8 +544,10 @@ define float @select_fcmp_nnan_nsz_olt_negzero_unary_fneg(float %x) {
|
||||
|
||||
define float @select_fcmp_nnan_nsz_ult_negzero_unary_fneg(float %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ult_negzero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf nsz float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: ret float [[TMP1]]
|
||||
; CHECK-NEXT: [[LTZERO:%.*]] = fcmp ult float [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan ninf nsz float [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LTZERO]], float [[NEGX]], float [[X]]
|
||||
; CHECK-NEXT: ret float [[FABS]]
|
||||
;
|
||||
%ltzero = fcmp ult float %x, -0.0
|
||||
%negx = fneg nnan ninf nsz float %x
|
||||
@ -543,8 +559,10 @@ define float @select_fcmp_nnan_nsz_ult_negzero_unary_fneg(float %x) {
|
||||
|
||||
define double @select_fcmp_nnan_nsz_ole_zero(double %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ole_zero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: ret double [[TMP1]]
|
||||
; CHECK-NEXT: [[LEZERO:%.*]] = fcmp ole double [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg fast double [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LEZERO]], double [[NEGX]], double [[X]]
|
||||
; CHECK-NEXT: ret double [[FABS]]
|
||||
;
|
||||
%lezero = fcmp ole double %x, 0.0
|
||||
%negx = fsub fast double -0.0, %x
|
||||
@ -554,7 +572,7 @@ define double @select_fcmp_nnan_nsz_ole_zero(double %x) {
|
||||
|
||||
define double @select_fast_fcmp_nnan_nsz_ole_zero(double %x) {
|
||||
; CHECK-LABEL: @select_fast_fcmp_nnan_nsz_ole_zero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: ret double [[TMP1]]
|
||||
;
|
||||
%lezero = fcmp ole double %x, 0.0
|
||||
@ -567,8 +585,10 @@ define double @select_fast_fcmp_nnan_nsz_ole_zero(double %x) {
|
||||
|
||||
define double @select_fcmp_nnan_nsz_ule_zero(double %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ule_zero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: ret double [[TMP1]]
|
||||
; CHECK-NEXT: [[LEZERO:%.*]] = fcmp ule double [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg fast double [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LEZERO]], double [[NEGX]], double [[X]]
|
||||
; CHECK-NEXT: ret double [[FABS]]
|
||||
;
|
||||
%lezero = fcmp ule double %x, 0.0
|
||||
%negx = fsub fast double -0.0, %x
|
||||
@ -578,8 +598,10 @@ define double @select_fcmp_nnan_nsz_ule_zero(double %x) {
|
||||
|
||||
define double @select_fcmp_nnan_nsz_ole_zero_unary_fneg(double %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ole_zero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: ret double [[TMP1]]
|
||||
; CHECK-NEXT: [[LEZERO:%.*]] = fcmp ole double [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg fast double [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LEZERO]], double [[NEGX]], double [[X]]
|
||||
; CHECK-NEXT: ret double [[FABS]]
|
||||
;
|
||||
%lezero = fcmp ole double %x, 0.0
|
||||
%negx = fneg fast double %x
|
||||
@ -591,8 +613,10 @@ define double @select_fcmp_nnan_nsz_ole_zero_unary_fneg(double %x) {
|
||||
|
||||
define double @select_fcmp_nnan_nsz_ule_zero_unary_fneg(double %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ule_zero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.fabs.f64(double [[X:%.*]])
|
||||
; CHECK-NEXT: ret double [[TMP1]]
|
||||
; CHECK-NEXT: [[LEZERO:%.*]] = fcmp ule double [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg fast double [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LEZERO]], double [[NEGX]], double [[X]]
|
||||
; CHECK-NEXT: ret double [[FABS]]
|
||||
;
|
||||
%lezero = fcmp ule double %x, 0.0
|
||||
%negx = fneg fast double %x
|
||||
@ -604,8 +628,10 @@ define double @select_fcmp_nnan_nsz_ule_zero_unary_fneg(double %x) {
|
||||
|
||||
define float @select_fcmp_nnan_nsz_ole_negzero(float %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ole_negzero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: ret float [[TMP1]]
|
||||
; CHECK-NEXT: [[LEZERO:%.*]] = fcmp ole float [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz float [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LEZERO]], float [[NEGX]], float [[X]]
|
||||
; CHECK-NEXT: ret float [[FABS]]
|
||||
;
|
||||
%lezero = fcmp ole float %x, -0.0
|
||||
%negx = fsub nnan nsz float -0.0, %x
|
||||
@ -628,8 +654,10 @@ define float @select_nnan_nsz_fcmp_nnan_nsz_ole_negzero(float %x) {
|
||||
|
||||
define float @select_fcmp_nnan_nsz_ule_negzero(float %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ule_negzero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: ret float [[TMP1]]
|
||||
; CHECK-NEXT: [[LEZERO:%.*]] = fcmp ule float [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz float [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LEZERO]], float [[NEGX]], float [[X]]
|
||||
; CHECK-NEXT: ret float [[FABS]]
|
||||
;
|
||||
%lezero = fcmp ule float %x, -0.0
|
||||
%negx = fsub nnan nsz float -0.0, %x
|
||||
@ -639,8 +667,10 @@ define float @select_fcmp_nnan_nsz_ule_negzero(float %x) {
|
||||
|
||||
define float @select_fcmp_nnan_nsz_ole_negzero_unary_fneg(float %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ole_negzero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: ret float [[TMP1]]
|
||||
; CHECK-NEXT: [[LEZERO:%.*]] = fcmp ole float [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz float [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LEZERO]], float [[NEGX]], float [[X]]
|
||||
; CHECK-NEXT: ret float [[FABS]]
|
||||
;
|
||||
%lezero = fcmp ole float %x, -0.0
|
||||
%negx = fneg nnan nsz float %x
|
||||
@ -652,8 +682,10 @@ define float @select_fcmp_nnan_nsz_ole_negzero_unary_fneg(float %x) {
|
||||
|
||||
define float @select_fcmp_nnan_nsz_ule_negzero_unary_fneg(float %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ule_negzero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: ret float [[TMP1]]
|
||||
; CHECK-NEXT: [[LEZERO:%.*]] = fcmp ule float [[X:%.*]], 0.000000e+00
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz float [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LEZERO]], float [[NEGX]], float [[X]]
|
||||
; CHECK-NEXT: ret float [[FABS]]
|
||||
;
|
||||
%lezero = fcmp ule float %x, -0.0
|
||||
%negx = fneg nnan nsz float %x
|
||||
@ -665,8 +697,10 @@ define float @select_fcmp_nnan_nsz_ule_negzero_unary_fneg(float %x) {
|
||||
|
||||
define <2 x float> @select_fcmp_nnan_nsz_ogt_zero(<2 x float> %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ogt_zero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz arcp <2 x float> @llvm.fabs.v2f32(<2 x float> [[X:%.*]])
|
||||
; CHECK-NEXT: ret <2 x float> [[TMP1]]
|
||||
; CHECK-NEXT: [[GTZERO:%.*]] = fcmp ogt <2 x float> [[X:%.*]], zeroinitializer
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz arcp <2 x float> [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select <2 x i1> [[GTZERO]], <2 x float> [[X]], <2 x float> [[NEGX]]
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%gtzero = fcmp ogt <2 x float> %x, zeroinitializer
|
||||
%negx = fsub nnan nsz arcp <2 x float> <float -0.0, float -0.0>, %x
|
||||
@ -678,8 +712,10 @@ define <2 x float> @select_fcmp_nnan_nsz_ogt_zero(<2 x float> %x) {
|
||||
|
||||
define <2 x float> @select_fcmp_nnan_nsz_ugt_zero(<2 x float> %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ugt_zero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz arcp <2 x float> @llvm.fabs.v2f32(<2 x float> [[X:%.*]])
|
||||
; CHECK-NEXT: ret <2 x float> [[TMP1]]
|
||||
; CHECK-NEXT: [[GTZERO:%.*]] = fcmp ugt <2 x float> [[X:%.*]], zeroinitializer
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz arcp <2 x float> [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select <2 x i1> [[GTZERO]], <2 x float> [[X]], <2 x float> [[NEGX]]
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%gtzero = fcmp ugt <2 x float> %x, zeroinitializer
|
||||
%negx = fsub nnan nsz arcp <2 x float> <float -0.0, float -0.0>, %x
|
||||
@ -689,8 +725,10 @@ define <2 x float> @select_fcmp_nnan_nsz_ugt_zero(<2 x float> %x) {
|
||||
|
||||
define <2 x float> @select_fcmp_nnan_nsz_ogt_zero_unary_fneg(<2 x float> %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ogt_zero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz arcp <2 x float> @llvm.fabs.v2f32(<2 x float> [[X:%.*]])
|
||||
; CHECK-NEXT: ret <2 x float> [[TMP1]]
|
||||
; CHECK-NEXT: [[GTZERO:%.*]] = fcmp ogt <2 x float> [[X:%.*]], zeroinitializer
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz arcp <2 x float> [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select <2 x i1> [[GTZERO]], <2 x float> [[X]], <2 x float> [[NEGX]]
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%gtzero = fcmp ogt <2 x float> %x, zeroinitializer
|
||||
%negx = fneg nnan nsz arcp <2 x float> %x
|
||||
@ -702,8 +740,10 @@ define <2 x float> @select_fcmp_nnan_nsz_ogt_zero_unary_fneg(<2 x float> %x) {
|
||||
|
||||
define <2 x float> @select_fcmp_nnan_nsz_ugt_zero_unary_fneg(<2 x float> %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ugt_zero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz arcp <2 x float> @llvm.fabs.v2f32(<2 x float> [[X:%.*]])
|
||||
; CHECK-NEXT: ret <2 x float> [[TMP1]]
|
||||
; CHECK-NEXT: [[GTZERO:%.*]] = fcmp ugt <2 x float> [[X:%.*]], zeroinitializer
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz arcp <2 x float> [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select <2 x i1> [[GTZERO]], <2 x float> [[X]], <2 x float> [[NEGX]]
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%gtzero = fcmp ugt <2 x float> %x, zeroinitializer
|
||||
%negx = fneg nnan nsz arcp <2 x float> %x
|
||||
@ -715,8 +755,10 @@ define <2 x float> @select_fcmp_nnan_nsz_ugt_zero_unary_fneg(<2 x float> %x) {
|
||||
|
||||
define half @select_fcmp_nnan_nsz_ogt_negzero(half %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ogt_negzero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast half @llvm.fabs.f16(half [[X:%.*]])
|
||||
; CHECK-NEXT: ret half [[TMP1]]
|
||||
; CHECK-NEXT: [[GTZERO:%.*]] = fcmp ogt half [[X:%.*]], 0xH0000
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg fast half [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[GTZERO]], half [[X]], half [[NEGX]]
|
||||
; CHECK-NEXT: ret half [[FABS]]
|
||||
;
|
||||
%gtzero = fcmp ogt half %x, -0.0
|
||||
%negx = fsub fast half 0.0, %x
|
||||
@ -728,8 +770,10 @@ define half @select_fcmp_nnan_nsz_ogt_negzero(half %x) {
|
||||
|
||||
define half @select_fcmp_nnan_nsz_ugt_negzero(half %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_ugt_negzero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast half @llvm.fabs.f16(half [[X:%.*]])
|
||||
; CHECK-NEXT: ret half [[TMP1]]
|
||||
; CHECK-NEXT: [[GTZERO:%.*]] = fcmp ugt half [[X:%.*]], 0xH0000
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg fast half [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[GTZERO]], half [[X]], half [[NEGX]]
|
||||
; CHECK-NEXT: ret half [[FABS]]
|
||||
;
|
||||
%gtzero = fcmp ugt half %x, -0.0
|
||||
%negx = fsub fast half 0.0, %x
|
||||
@ -741,8 +785,10 @@ define half @select_fcmp_nnan_nsz_ugt_negzero(half %x) {
|
||||
|
||||
define <2 x double> @select_fcmp_nnan_nsz_oge_zero(<2 x double> %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_oge_zero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call reassoc nnan nsz <2 x double> @llvm.fabs.v2f64(<2 x double> [[X:%.*]])
|
||||
; CHECK-NEXT: ret <2 x double> [[TMP1]]
|
||||
; CHECK-NEXT: [[GEZERO:%.*]] = fcmp oge <2 x double> [[X:%.*]], zeroinitializer
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg reassoc nnan nsz <2 x double> [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select <2 x i1> [[GEZERO]], <2 x double> [[X]], <2 x double> [[NEGX]]
|
||||
; CHECK-NEXT: ret <2 x double> [[FABS]]
|
||||
;
|
||||
%gezero = fcmp oge <2 x double> %x, zeroinitializer
|
||||
%negx = fsub nnan nsz reassoc <2 x double> <double -0.0, double -0.0>, %x
|
||||
@ -754,8 +800,10 @@ define <2 x double> @select_fcmp_nnan_nsz_oge_zero(<2 x double> %x) {
|
||||
|
||||
define <2 x double> @select_fcmp_nnan_nsz_uge_zero(<2 x double> %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_uge_zero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call reassoc nnan nsz <2 x double> @llvm.fabs.v2f64(<2 x double> [[X:%.*]])
|
||||
; CHECK-NEXT: ret <2 x double> [[TMP1]]
|
||||
; CHECK-NEXT: [[GEZERO:%.*]] = fcmp uge <2 x double> [[X:%.*]], zeroinitializer
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg reassoc nnan nsz <2 x double> [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select <2 x i1> [[GEZERO]], <2 x double> [[X]], <2 x double> [[NEGX]]
|
||||
; CHECK-NEXT: ret <2 x double> [[FABS]]
|
||||
;
|
||||
%gezero = fcmp uge <2 x double> %x, zeroinitializer
|
||||
%negx = fsub nnan nsz reassoc <2 x double> <double -0.0, double -0.0>, %x
|
||||
@ -765,8 +813,10 @@ define <2 x double> @select_fcmp_nnan_nsz_uge_zero(<2 x double> %x) {
|
||||
|
||||
define <2 x double> @select_fcmp_nnan_nsz_oge_zero_unary_fneg(<2 x double> %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_oge_zero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call reassoc nnan nsz <2 x double> @llvm.fabs.v2f64(<2 x double> [[X:%.*]])
|
||||
; CHECK-NEXT: ret <2 x double> [[TMP1]]
|
||||
; CHECK-NEXT: [[GEZERO:%.*]] = fcmp oge <2 x double> [[X:%.*]], zeroinitializer
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg reassoc nnan nsz <2 x double> [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select <2 x i1> [[GEZERO]], <2 x double> [[X]], <2 x double> [[NEGX]]
|
||||
; CHECK-NEXT: ret <2 x double> [[FABS]]
|
||||
;
|
||||
%gezero = fcmp oge <2 x double> %x, zeroinitializer
|
||||
%negx = fneg nnan nsz reassoc <2 x double> %x
|
||||
@ -778,8 +828,10 @@ define <2 x double> @select_fcmp_nnan_nsz_oge_zero_unary_fneg(<2 x double> %x) {
|
||||
|
||||
define <2 x double> @select_fcmp_nnan_nsz_uge_zero_unary_fneg(<2 x double> %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_uge_zero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call reassoc nnan nsz <2 x double> @llvm.fabs.v2f64(<2 x double> [[X:%.*]])
|
||||
; CHECK-NEXT: ret <2 x double> [[TMP1]]
|
||||
; CHECK-NEXT: [[GEZERO:%.*]] = fcmp uge <2 x double> [[X:%.*]], zeroinitializer
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg reassoc nnan nsz <2 x double> [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select <2 x i1> [[GEZERO]], <2 x double> [[X]], <2 x double> [[NEGX]]
|
||||
; CHECK-NEXT: ret <2 x double> [[FABS]]
|
||||
;
|
||||
%gezero = fcmp uge <2 x double> %x, zeroinitializer
|
||||
%negx = fneg nnan nsz reassoc <2 x double> %x
|
||||
@ -791,8 +843,10 @@ define <2 x double> @select_fcmp_nnan_nsz_uge_zero_unary_fneg(<2 x double> %x) {
|
||||
|
||||
define half @select_fcmp_nnan_nsz_oge_negzero(half %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_oge_negzero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz half @llvm.fabs.f16(half [[X:%.*]])
|
||||
; CHECK-NEXT: ret half [[TMP1]]
|
||||
; CHECK-NEXT: [[GEZERO:%.*]] = fcmp oge half [[X:%.*]], 0xH0000
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz half [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[GEZERO]], half [[X]], half [[NEGX]]
|
||||
; CHECK-NEXT: ret half [[FABS]]
|
||||
;
|
||||
%gezero = fcmp oge half %x, -0.0
|
||||
%negx = fsub nnan nsz half -0.0, %x
|
||||
@ -804,8 +858,10 @@ define half @select_fcmp_nnan_nsz_oge_negzero(half %x) {
|
||||
|
||||
define half @select_fcmp_nnan_nsz_uge_negzero(half %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_uge_negzero(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz half @llvm.fabs.f16(half [[X:%.*]])
|
||||
; CHECK-NEXT: ret half [[TMP1]]
|
||||
; CHECK-NEXT: [[GEZERO:%.*]] = fcmp uge half [[X:%.*]], 0xH0000
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz half [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[GEZERO]], half [[X]], half [[NEGX]]
|
||||
; CHECK-NEXT: ret half [[FABS]]
|
||||
;
|
||||
%gezero = fcmp uge half %x, -0.0
|
||||
%negx = fsub nnan nsz half -0.0, %x
|
||||
@ -815,8 +871,10 @@ define half @select_fcmp_nnan_nsz_uge_negzero(half %x) {
|
||||
|
||||
define half @select_fcmp_nnan_nsz_oge_negzero_unary_fneg(half %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_oge_negzero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz half @llvm.fabs.f16(half [[X:%.*]])
|
||||
; CHECK-NEXT: ret half [[TMP1]]
|
||||
; CHECK-NEXT: [[GEZERO:%.*]] = fcmp oge half [[X:%.*]], 0xH0000
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz half [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[GEZERO]], half [[X]], half [[NEGX]]
|
||||
; CHECK-NEXT: ret half [[FABS]]
|
||||
;
|
||||
%gezero = fcmp oge half %x, -0.0
|
||||
%negx = fneg nnan nsz half %x
|
||||
@ -828,8 +886,10 @@ define half @select_fcmp_nnan_nsz_oge_negzero_unary_fneg(half %x) {
|
||||
|
||||
define half @select_fcmp_nnan_nsz_uge_negzero_unary_fneg(half %x) {
|
||||
; CHECK-LABEL: @select_fcmp_nnan_nsz_uge_negzero_unary_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz half @llvm.fabs.f16(half [[X:%.*]])
|
||||
; CHECK-NEXT: ret half [[TMP1]]
|
||||
; CHECK-NEXT: [[GEZERO:%.*]] = fcmp uge half [[X:%.*]], 0xH0000
|
||||
; CHECK-NEXT: [[NEGX:%.*]] = fneg nnan nsz half [[X]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = select i1 [[GEZERO]], half [[X]], half [[NEGX]]
|
||||
; CHECK-NEXT: ret half [[FABS]]
|
||||
;
|
||||
%gezero = fcmp uge half %x, -0.0
|
||||
%negx = fneg nnan nsz half %x
|
||||
|
Loading…
Reference in New Issue
Block a user