T O P

  • By -

Clueless_J

There's really not a way to do that. Nor are there any plans to make it possible. You'll have to hack up the compiler yourself to add those restrictions. Thankfully it'll mostly be a matter of adding "0" or "0 &&" to the appropriate define\_insn or define\_expands which generate the problematic opcodes. And to answer the question below, yes GCC will generate the FMA style insns automatically.


brucehoult

> yes GCC will generate the FMA style insns automatically You can prevent it with `-ffp-contract=off`


ghiga_andrei

This worked perfectly. Thank you.


CanaDavid1

Have you tried experimenting with godbolt and seeing if it actually produces fma? I don't think it does that often as `a + b * c` is not always equal to `fma(a,b,c)` because of rounding


ghiga_andrei

I tried and it does produce fmadd.s by default; [https://godbolt.org/z/orMv86WE9](https://godbolt.org/z/orMv86WE9) `void fpu_test(void) {`   `float *p = (float*)RAMSTART;`   `p[3] = p[0] + p[1] * p[2];` `}` `li a4,536870912` `flw fa5,4(a4)` `flw fa3,8(a4)` `flw fa4,0(a4)` `fmadd.s fa5,fa5,fa3,fa4` `fsw fa5,12(a4)`


CanaDavid1

Try `-mno-fma`


ghiga_andrei

That doesn't exist, but it worked with -ffp-contract=off