[clang] [llvm] [InstCombine] Combine llvm.sin/llvm.cos libcall pairs into llvm.sincos (PR #184760)

Kito Cheng via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 12 07:25:06 PDT 2026


================
@@ -3067,21 +3074,41 @@ Value *LibCallSimplifier::optimizeSinCosPi(CallInst *CI, bool IsSin, IRBuilderBa
 
   bool IsFloat = Arg->getType()->isFloatTy();
 
-  // Look for all compatible sinpi, cospi and sincospi calls with the same
+  // Look for all compatible sin/cos (or sinpi/cospi) calls with the same
   // argument. If there are enough (in some sense) we can make the
   // substitution.
   Function *F = CI->getFunction();
   for (User *U : Arg->users())
-    classifyArgUse(U, F, IsFloat, SinCalls, CosCalls, SinCosCalls);
+    classifyArgUse(U, F, IsFloat, SinCalls, CosCalls, SinCosCalls, IsPi);
----------------
kito-cheng wrote:

Thanks for the context! Since ConstantData args are already excluded (I've also added the same filter in my latest `InstCombine` version in the PR) and float args can't be global variables, I think the current approach should be fine for the sin/cos case.

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


More information about the llvm-commits mailing list