diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index c5a2c2f52f8dc..88db315ffd0bc 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -2407,6 +2407,9 @@ static Constant *ConstantFoldScalarCall1(StringRef Name, break; case LibFunc_log1p: case LibFunc_log1pf: + // Implement optional behavior from C's Annex F for +/-0.0. + if (U.isZero()) + return ConstantFP::get(Ty->getContext(), U); if (APF > APFloat::getOne(APF.getSemantics(), true) && TLI->has(Func)) return ConstantFoldFP(log1p, APF, Ty); break; diff --git a/llvm/test/Transforms/InstCombine/log1p.ll b/llvm/test/Transforms/InstCombine/log1p.ll index bbf89db8c3410..81d3cc8a4f7ac 100644 --- a/llvm/test/Transforms/InstCombine/log1p.ll +++ b/llvm/test/Transforms/InstCombine/log1p.ll @@ -1,4 +1,3 @@ -; XFAIL: target={{.*}}-aix{{.*}} ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s