Skip to content

ecc/fourq: fix legacy (non-BMI2) GF(p^2) multiplication on amd64 - #669

Merged
bwesterb merged 1 commit into
mainfrom
bas/gw52
Jul 31, 2026
Merged

ecc/fourq: fix legacy (non-BMI2) GF(p^2) multiplication on amd64#669
bwesterb merged 1 commit into
mainfrom
bas/gw52

Conversation

@bwesterb

@bwesterb bwesterb commented Jul 31, 2026

Copy link
Copy Markdown
Member

_fqMulLeg folded a negative c0 = a0b0 - a1b1 with

SHLQ $1,R10 / BTRQ $63,R9 / ADCQ R10,R8 / ADCQ R14,R9

SHLQ's carry-out is overwritten by the following BTRQ, so the top bit is lost. R14, the sign extension of the borrow, is added plain instead of double. Finally the carry out is dropped. These three errors cancel most of the time, but not always.

Fix and add regression tests.


Open in Devin Review

_fqMulLeg folded a negative c0 = a0*b0 - a1*b1 with

    SHLQ $1,R10 / BTRQ $63,R9 / ADCQ R10,R8 / ADCQ R14,R9

SHLQ's carry-out is overwritten by the following BTRQ, so the top bit is
lost. R14, the sign extension of the borrow, is added plain instead of
double. Finally the carry out is dropped. These three errors cancel most
of the time, but not always.

Fix and add regression tests.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@bwesterb
bwesterb merged commit e6b4719 into main Jul 31, 2026
14 checks passed
@bwesterb
bwesterb deleted the bas/gw52 branch July 31, 2026 15:39
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