[llvm] [NVVM] mark math intrinsics as speculatable, default-attrs (PR #94481)
Alex MacLean via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 6 06:50:24 PDT 2024
================
@@ -691,51 +691,51 @@ let TargetPrefix = "nvvm" in {
def int_nvvm_div_approx_ftz_f : ClangBuiltin<"__nvvm_div_approx_ftz_f">,
DefaultAttrsIntrinsic<[llvm_float_ty], [llvm_float_ty, llvm_float_ty],
- [IntrNoMem]>;
+ [IntrNoMem, IntrSpeculatable]>;
----------------
AlexMaclean wrote:
> Do we want to speculate something as expensive as division?
I can think of some cases where it would be good to speculate division. For example, it would help perf overall (especially in cases we care about) if LICM could hoist divisions out of loops, even when it can't prove they are going to be executed (this could be due to something as simple as inline asm which we can't assume will return).
> I do not think we have a good way to model costs for the expensive instructions
What about the TTI `getInstructionCost`? I think SimplifyCFG checks this before folding a 2 entry phi, shouldn't other passes be doing so as well if they're speculating instructions. If not, that leave the problem of the `fdiv` instruction, which is similarly expensive.
https://github.com/llvm/llvm-project/pull/94481
More information about the llvm-commits
mailing list