[llvm] [SimplifyLibCalls] Move constant folding logic in `ConstantFoldLibCall2` (PR #172139)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 16 05:54:51 PST 2025
================
@@ -3241,6 +3241,15 @@ static Constant *ConstantFoldLibCall2(StringRef Name, Type *Ty,
if (TLI->has(Func))
return ConstantFoldBinaryFP(atan2, Op1V, Op2V, Ty);
break;
+ case LibFunc_fdim:
+ case LibFunc_fdimf:
+ case LibFunc_fdiml:
+ APFloat Difference = Op1V;
+ Difference.subtract(Op2V, RoundingMode::NearestTiesToEven);
+
+ APFloat MaxVal =
+ maximum(Difference, APFloat::getZero(Ty->getFltSemantics()));
----------------
arsenm wrote:
The actual implementation logic should probably be in APFloat
https://github.com/llvm/llvm-project/pull/172139
More information about the llvm-commits
mailing list