[llvm] [TLI] Add getLibFunc in TLI API that accepts an Instruction. (PR #75919)
Alexandros Lamprineas via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 06:04:48 PST 2023
================
@@ -1149,6 +1149,20 @@ bool TargetLibraryInfoImpl::getLibFunc(const Function &FDecl,
return isValidProtoForLibFunc(*FDecl.getFunctionType(), F, *M);
}
+bool TargetLibraryInfoImpl::getLibFunc(const Instruction &I, LibFunc &F) const {
+ if (I.getOpcode() != Instruction::FRem)
+ return false;
+
----------------
labrinea wrote:
I would write it as
```
Type *ScalarTy = I.getType()->getScalarType();
if (!ScalarTy->isDoubleTy() && !ScalarTy->isFloatTy())
return false;
F = ScalarTy->isDoubleTy() ? LibFunc_fmod : LibFunc_fmodf;
return true;
```
https://github.com/llvm/llvm-project/pull/75919
More information about the llvm-commits
mailing list