Skip to content

Дормидонтов Егор. Лабораторная работа 3. Backend. Вариант 4. #196

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

Open
wants to merge 1 commit into
base: course-spring-2025
Choose a base branch
from

Conversation

EgorDormidontov
Copy link

FmsubOptPass - пасс, который на этапе генерации машинного кода ищет и оптимизирует последовательности операций умножения и вычитания (или сложения с отрицанием), используя инструкции FMA/FMSUB.

Пасс распознаёт следующие шаблоны:

  1. (a * b) - c
    Заменяется на инструкцию VFMSUB213, что соответствует fused multiply-subtract (FMSUB).

  2. c - (a * b)
    Заменяется на VFNMADD213 — fused negative multiply-add (FNMADD).

  3. -(a * b) + c
    (или через XOR/NEG) также заменяется на VFNMADD213.

Пасс покрывает оба варианта SIMD/скалярных инструкций:

SSE/SSE2: MULSSrr, MULSDrr, SUBSSrr, SUBSDrr, ADDSSrr, ADDSDrr и их packed-аналоги.
AVX/FMA: VMULSSrr, VMULSDrr, VSUBSSrr, VSUBSDrr, VADDSSrr, VADDSDrr и packed-варианты.

Comment on lines +46 to +47
# CHECK-LABEL: name: _Z6mulsubfff
# CHECK: VFMSUB213SSr

Choose a reason for hiding this comment

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

These CHECKs are not checking register correctness in the new instruction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants