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

svg: Prevent code with fused instructions #464

Merged
merged 3 commits into from
Feb 8, 2025
Merged

svg: Prevent code with fused instructions #464

merged 3 commits into from
Feb 8, 2025

Conversation

camh-
Copy link
Member

@camh- camh- commented Feb 8, 2025

Add a floating point conversion when multiplying when scaling coordinates
so that the multiplication does not get fused with an adjacent addition or
subtraction. This causes two instructions to be generated, a MUL and a
ADD/SUB, instead of a single FMADD or FMSUB. A fused instruction has
different rounding so ends up giving slightly different results to two
instructions. This was causing different values in the SVGs generated
between AMD64 and ARM64.

Revert "labs: Rework random rectangle generation" as we no longer need
to work around this by rounding in Evy code.

Remove the parens in randrect.evy as they are not needed any more due
to a recent change.

I've tested this on AMD64 and ARM64 and the same SVGs are now generated.

Link: https://go.dev/ref/spec#Floating_point_operators

camh- added 2 commits February 8, 2025 21:08
Add a floating point conversion when multiplying when scaling
coordinates so that the multiplication does not get fused with an
adjacent addition or subtraction. This causes two instructions to be
generated, a MUL and a ADD/SUB, instead of a single FMADD or FMSUB.
A fused instruction has different rounding so ends up giving slightly
different results to two instructions. This was causing different values
in the SVGs generated between AMD64 and ARM64.

Link: https://go.dev/ref/spec#Floating_point_operators
This should not be needed now that we have identified the cause of the
difference being fused instructions, which are no longer generated.

Commit: 6f2a675
Remove the parens around `rand1` in `randrect.evy` as they are no longer
needed due to a recent change that allows niladic function calls in
expressions without parens.

Since this PR is in this file now, let's make it read nicer. There are
probably other evy files that could have this change - one day we may
find them.
Copy link
Member

@juliaogris juliaogris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful, thank you!💚

@camh- camh- merged commit b13ec7a into main Feb 8, 2025
4 checks passed
@camh- camh- deleted the unfuse-multiply branch February 8, 2025 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants