diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 26432d2eed5e..bb1cbfade34d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2839,10 +2839,11 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) { // Avoid lossy conversions and denormals. Zero is a special case // that's OK to convert. - F.clearSign(); + APFloat Fabs = F; + Fabs.clearSign(); if (!Lossy && - ((F.compare(APFloat::getSmallestNormalized(*Sem)) != - APFloat::cmpLessThan) || F.isZero())) + ((Fabs.compare(APFloat::getSmallestNormalized(*Sem)) != + APFloat::cmpLessThan) || Fabs.isZero())) return new FCmpInst(I.getPredicate(), LHSExt->getOperand(0), ConstantFP::get(RHSC->getContext(), F));