[llvm] [SimplifyLibCalls] Shrink llvm.sincos.f64 to llvm.sincos.f32 (PR #211218)
Kito Cheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 23 00:10:43 PDT 2026
================
@@ -2047,6 +2047,41 @@ static Value *optimizeBinaryDoubleFP(CallInst *CI, IRBuilderBase &B,
return optimizeDoubleFP(CI, B, true, TLI, isPrecise);
}
+/// Shrink double -> float for llvm.sincos.
+static Value *optimizeSinCosDoubleFP(CallInst *CI, IRBuilderBase &B) {
+ auto *RetTy = dyn_cast<StructType>(CI->getType());
+ if (!RetTy || RetTy->getNumElements() != 2 ||
+ !RetTy->getElementType(0)->isDoubleTy())
+ return nullptr;
+
+ Value *X = valueHasFloatPrecision(CI->getArgOperand(0));
+ if (!X)
+ return nullptr;
+
+ for (User *U : CI->users()) {
+ auto *EV = dyn_cast<ExtractValueInst>(U);
+ if (!EV)
+ return nullptr;
+ for (User *EVU : EV->users()) {
+ auto *Cast = dyn_cast<FPTruncInst>(EVU);
+ if (!Cast || !Cast->getType()->isFloatTy())
----------------
kito-cheng wrote:
I may found some time to handle other `double -> float` together latter
https://github.com/llvm/llvm-project/pull/211218
More information about the llvm-commits
mailing list