[llvm] [flang-rt] Consider NaN and the signedness of zero for PRODUCT (PR #226918)
Yusuke MINATO via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 19:54:14 PDT 2026
yus3710-fj wrote:
> > I forgot to mention the performance impact.
>
> I did not bother asking about it, because I am not too worried about the `-O0` performance. But I was under an impression that we inline `product` always, and maybe I am wrong. Are there limitations that prevent us from inlining `product`?
Apologies for the confusion; my wording may have been misleading.
Generally, PRODUCT is inlined at -O1 or higher. However, there is a special case:
https://github.com/llvm/llvm-project/blob/779a0f4938d487a97c82ea583c30501327ba6dff/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp#L1150-L1152
If the reduction dimension is mutable, inlining is still possible, but the generated code would require branching (e.g., https://godbolt.org/z/3aTrjMY7v). We currently avoid doing this. This applies not only to PRODUCT but also to other reduction intrinsics, such as SUM.
https://github.com/llvm/llvm-project/pull/226918
More information about the llvm-commits
mailing list