Skip to content

Commit c171c4d

Browse files
committed
[ConstantFolding] Added ilogb in isMathLibCallNoop()
ilogb libcall was not being constant folded correctly. This patch adds ilogb with its correct domain in isMathLibCallNoop(). Fixes #101873
1 parent 5f29f64 commit c171c4d

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3806,7 +3806,8 @@ bool llvm::isMathLibCallNoop(const CallBase *Call,
38063806
case LibFunc_log10:
38073807
case LibFunc_log10f:
38083808
return Op.isNaN() || (!Op.isZero() && !Op.isNegative());
3809-
3809+
case LibFunc_ilogb:
3810+
return !(Op.isNaN()) && !(Op.isZero() || Op.isInfinity());
38103811
case LibFunc_expl:
38113812
case LibFunc_exp:
38123813
case LibFunc_expf:

llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ bool LibCallsShrinkWrap::performCallErrors(CallInst *CI,
246246
case LibFunc_logb: // Same as log
247247
case LibFunc_logbf: // Same as log
248248
case LibFunc_logbl: // Same as log
249-
case LibFunc_ilogb: // Same as log
250249
{
251250
++NumWrappedOneCond;
252251
Cond = createCond(CI, CmpInst::FCMP_OLE, 0.0f);

llvm/test/Transforms/Util/libcalls-shrinkwrap-float.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ entry:
334334
; CHECK-NEXT: %call_11 = call float @log1pf(float %value)
335335
; CHECK-NEXT: br label %[[END_LABEL]]
336336
; CHECK: [[END_LABEL]]:
337+
338+
%call_12 = call i32 @ilogb(float %value) strictfp
337339
ret void
338340
}
339341

0 commit comments

Comments
 (0)