[llvm] [InstCombine] Convert @log to @llvm.log if the input is known positive. (PR #111428)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 13:08:53 PDT 2024
================
@@ -2589,10 +2584,26 @@ Value *LibCallSimplifier::optimizeLog(CallInst *Log, IRBuilderBase &B) {
PowLb = LibFunc_powl;
break;
default:
- return Ret;
+ return nullptr;
+ }
+
+ // Convert libcall to intrinsic if the value is known > 0.
+ bool IsKnownNoErrno = Log->hasNoNaNs() && Log->hasNoInfs();
+ if (!IsKnownNoErrno) {
+ SimplifyQuery SQ(DL, TLI, DT, AC, Log, true, true, DC);
+ KnownFPClass Known = computeKnownFPClass(
+ Log->getOperand(0), KnownFPClass::OrderedLessThanZeroMask,
+ /*Depth=*/0, SQ);
+ IsKnownNoErrno =
+ Known.isKnownNeverZero() && Known.cannotBeOrderedLessThanZero();
----------------
arsenm wrote:
Broken for DAZ, you want isKnownNeverLogicalZero (we should probably remove isKnownNeverZero)
https://github.com/llvm/llvm-project/pull/111428
More information about the llvm-commits
mailing list