[clang] [llvm] Reimplement constrained 'trunc' using operand bundles (PR #118253)
Kevin P. Neal via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 13:29:29 PST 2024
================
@@ -86,6 +86,43 @@ IRBuilderBase::createCallHelper(Function *Callee, ArrayRef<Value *> Ops,
return CI;
}
+CallInst *IRBuilderBase::CreateCall(FunctionType *FTy, Value *Callee,
+ ArrayRef<Value *> Args,
+ ArrayRef<OperandBundleDef> OpBundles,
+ const Twine &Name, MDNode *FPMathTag) {
+ ArrayRef<OperandBundleDef> ActualBundlesRef = OpBundles;
+ SmallVector<OperandBundleDef, 2> ActualBundles;
+
+ if (IsFPConstrained) {
+ if (const auto *Func = dyn_cast<Function>(Callee)) {
+ if (Intrinsic::ID ID = Func->getIntrinsicID()) {
+ if (IntrinsicInst::canAccessFPEnvironment(ID)) {
+ bool NeedRound = true, NeedExcept = true;
+ for (const auto &Item : OpBundles) {
+ if (NeedRound && Item.getTag() == "fpe.round")
+ NeedRound = false;
+ else if (NeedExcept && Item.getTag() == "fpe.except")
+ NeedExcept = false;
+ ActualBundles.push_back(Item);
----------------
kpneal wrote:
Do we want intrinsics where the rounding mode is baked in (like trunc or floor) to be allowed to have a rounding mode bundle? Or, do we want the rounding mode bundle to be able to specify a rounding mode that isn't the one baked into the intrinsic? I'm leaning towards the rounding mode bundle not being allowed.
https://github.com/llvm/llvm-project/pull/118253
More information about the llvm-commits
mailing list