@@ -2863,22 +2863,20 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
2863
2863
}
2864
2864
2865
2865
// Canonicalize select with fcmp to fabs(). -0.0 makes this tricky. We need
2866
- // fast-math-flags (nsz) or fsub with +0.0 (not fneg) for this to work. We
2867
- // also require nnan because we do not want to unintentionally change the
2868
- // sign of a NaN value.
2866
+ // fast-math-flags (nsz) or fsub with +0.0 (not fneg) for this to work.
2869
2867
// (X <= +/-0.0) ? (0.0 - X) : X --> fabs(X)
2870
2868
Instruction *FSub;
2871
2869
if (match (CondVal, m_FCmp (Pred, m_Specific (FalseVal), m_AnyZeroFP ())) &&
2872
2870
match (TrueVal, m_FSub (m_PosZeroFP (), m_Specific (FalseVal))) &&
2873
- match (TrueVal, m_Instruction (FSub)) && FSub-> hasNoNaNs () &&
2871
+ match (TrueVal, m_Instruction (FSub)) &&
2874
2872
(Pred == FCmpInst::FCMP_OLE || Pred == FCmpInst::FCMP_ULE)) {
2875
2873
Value *Fabs = Builder.CreateUnaryIntrinsic (Intrinsic::fabs, FalseVal, &SI);
2876
2874
return replaceInstUsesWith (SI, Fabs);
2877
2875
}
2878
2876
// (X > +/-0.0) ? X : (0.0 - X) --> fabs(X)
2879
2877
if (match (CondVal, m_FCmp (Pred, m_Specific (TrueVal), m_AnyZeroFP ())) &&
2880
2878
match (FalseVal, m_FSub (m_PosZeroFP (), m_Specific (TrueVal))) &&
2881
- match (FalseVal, m_Instruction (FSub)) && FSub-> hasNoNaNs () &&
2879
+ match (FalseVal, m_Instruction (FSub)) &&
2882
2880
(Pred == FCmpInst::FCMP_OGT || Pred == FCmpInst::FCMP_UGT)) {
2883
2881
Value *Fabs = Builder.CreateUnaryIntrinsic (Intrinsic::fabs, TrueVal, &SI);
2884
2882
return replaceInstUsesWith (SI, Fabs);
@@ -2889,8 +2887,7 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
2889
2887
Instruction *FNeg;
2890
2888
if (match (CondVal, m_FCmp (Pred, m_Specific (FalseVal), m_AnyZeroFP ())) &&
2891
2889
match (TrueVal, m_FNeg (m_Specific (FalseVal))) &&
2892
- match (TrueVal, m_Instruction (FNeg)) && FNeg->hasNoNaNs () &&
2893
- FNeg->hasNoSignedZeros () && SI.hasNoSignedZeros () &&
2890
+ match (TrueVal, m_Instruction (FNeg)) && SI.hasNoSignedZeros () &&
2894
2891
(Pred == FCmpInst::FCMP_OLT || Pred == FCmpInst::FCMP_OLE ||
2895
2892
Pred == FCmpInst::FCMP_ULT || Pred == FCmpInst::FCMP_ULE)) {
2896
2893
Value *Fabs = Builder.CreateUnaryIntrinsic (Intrinsic::fabs, FalseVal, &SI);
@@ -2901,8 +2898,7 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
2901
2898
// (X >= +/-0.0) ? X : -X --> fabs(X)
2902
2899
if (match (CondVal, m_FCmp (Pred, m_Specific (TrueVal), m_AnyZeroFP ())) &&
2903
2900
match (FalseVal, m_FNeg (m_Specific (TrueVal))) &&
2904
- match (FalseVal, m_Instruction (FNeg)) && FNeg->hasNoNaNs () &&
2905
- FNeg->hasNoSignedZeros () && SI.hasNoSignedZeros () &&
2901
+ match (FalseVal, m_Instruction (FNeg)) && SI.hasNoSignedZeros () &&
2906
2902
(Pred == FCmpInst::FCMP_OGT || Pred == FCmpInst::FCMP_OGE ||
2907
2903
Pred == FCmpInst::FCMP_UGT || Pred == FCmpInst::FCMP_UGE)) {
2908
2904
Value *Fabs = Builder.CreateUnaryIntrinsic (Intrinsic::fabs, TrueVal, &SI);
0 commit comments