[llvm] [SimplifyLibCalls] Constant fold `remquo` (PR #99647)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 23 11:19:53 PDT 2024


================
@@ -3018,6 +3018,39 @@ void LibCallSimplifier::classifyArgUse(
   }
 }
 
+/// Constant folds remquo
+Value *LibCallSimplifier::optimizeRemquo(CallInst *CI, IRBuilderBase &B) {
+  const APFloat *X, *Y;
+  if (!match(CI->getArgOperand(0), m_APFloat(X)) ||
+      !match(CI->getArgOperand(1), m_APFloat(Y)))
+    return nullptr;
+
+  if (X->isNaN() || Y->isNaN() || X->isInfinity() || Y->isZero())
+    return nullptr;
----------------
dtcxzyw wrote:

It is guarded in
https://github.com/llvm/llvm-project/blob/e64e745e8fb802ffb06259b1a5ba3db713a17087/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp#L3819-L3826


https://github.com/llvm/llvm-project/pull/99647


More information about the llvm-commits mailing list