Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FPU] prevent GCC from emitting fused multiply-add instructions #905

Merged
merged 3 commits into from
May 18, 2024

Conversation

stnolting
Copy link
Owner

@stnolting stnolting commented May 18, 2024

The FPU of the Zfinx ISA extension does not support any fused /multiply-add instructions:

  • fmadd.s
  • fmsub.s
  • fnmsub.s
  • fnmadd.s

In order to prevent GCC from emitting such instruction a new compiler flag is added (-ffp-contract=off).

Without -ffp-contract=off (or -ffp-contract=on, which is the default): ❌

;fx = (f0 * f1) + f2;
218:  00012783  lw       a5,0(sp)
21c:  00412683  lw       a3,4(sp)
220:  00812703  lw       a4,8(sp)
224:  70d7f7c3  fmadd.s  a5,a5,a3,a4
228:  00f12623  sw       a5,12(sp)

With -ffp-contract=off: ✔️

;fx = (f0 * f1) + f2;
218:  00012783  lw      a5,0(sp)
21c:  00412683  lw      a3,4(sp)
220:  00812703  lw      a4,8(sp)
224:  10d7f7d3  fmul.s  a5,a5,a3
228:  00e7f7d3  fadd.s  a5,a5,a4
22c:  00f12623  sw      a5,12(sp)

Prevent GCC from emitting fused / multiply-add floating-point operations
@stnolting stnolting added SW software-related experimental Experimental feature labels May 18, 2024
@stnolting stnolting self-assigned this May 18, 2024
@stnolting stnolting marked this pull request as ready for review May 18, 2024 16:10
@stnolting stnolting merged commit 8468686 into main May 18, 2024
10 checks passed
@stnolting stnolting deleted the fpu_gcc branch May 18, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental Experimental feature SW software-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant