[llvm] [InstCombine] Fold fmod to frem if we know it does not set errno. (PR #107912)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 13 10:44:57 PDT 2024
================
@@ -2796,6 +2796,27 @@ Value *LibCallSimplifier::optimizeSqrt(CallInst *CI, IRBuilderBase &B) {
return copyFlags(*CI, FabsCall);
}
+Value *LibCallSimplifier::optimizeFMod(CallInst *CI, IRBuilderBase &B) {
+ SimplifyQuery SQ(DL, TLI, DT, AC, CI, true, true, DC);
+
+ // fmod(x,y) can set errno if y == 0 or x == +/-inf. Otherwise we can change
+ // it to a frem instruction.
+ KnownFPClass Known0 = computeKnownFPClass(CI->getOperand(0), fcInf,
----------------
arsenm wrote:
You can also just do this if the instruction has the nnan flag
https://github.com/llvm/llvm-project/pull/107912
More information about the llvm-commits
mailing list