# Why doesn’t Julia fma automatically?

**URL:** <https://discourse.julialang.org/t/why-doesn-t-julia-fma-automatically/104982>\
**Category:** General Usage\
**Created:** [October 13, 2023, 3:31am UTC](https://discourse.julialang.org/t/why-doesn-t-julia-fma-automatically/104982 "2023-10-13T03:31:53Z")\
**Posts on this page:** 1\
**Showing post:** 25

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [October 16, 2023, 4:14pm UTC](https://discourse.julialang.org/t/why-doesn-t-julia-fma-automatically/104982/25 "2023-10-16T16:14:33Z")

</div>

> Where did this idea come from that C and C++ do FMA automatically?

From Clang, I assume that means C and C++.

See my comment above, and where I’ve answered you on that before (I confirmed personally for Clang for RISC-V with Godbolt):

> [@X \* y + z does not automatically use FMA instruction](https://discourse.julialang.org/t/x-y-z-does-not-automatically-use-fma-instruction/100640/33):
>
> EDIT: That’s just not true in all cases. Clang does it by default depending on the arch, e.g. uses fmadd.d for RISC-V rv64gc clang 14.0.0 (changed from older versions; same change for 32-bit). It’s not only for -O1, also with -O0, or no options which I assume is the same. [It’s just that I overlooked when looking at boilerplate, the adds you see then are not for the floating point.] That’s not entirely true, depending on what you mean by you “asked for” it, and “by default”. I see I can get it…

> The C standard permits intermediate floating-point results within an expression to be computed with more precision than their type would normally allow. This permits operation fusing, and Clang takes advantage of this by default.

I believe Clang has an exeptions to its new default for x86… at least for now.

> [@StefanKarpinski](#):
>
> which is local to a compilation unit

Julia doesn’t have such, except well packages (precompiled by now), why I proposed a possible exception for them/libraries.

---

_[View the full topic](https://discourse.julialang.org/t/why-doesn-t-julia-fma-automatically/104982)._
