Skip to content

Ополин Дмитрий. Лабораторная работа 3. Backend. Вариант 1. #145

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

deademous
Copy link

Этот LLVM Pass выполняет оптимизацию логических операций (AND, OR, XOR и их комбинаций) для архитектуры X86, заменяя скалярные SSE-инструкции на более эффективные векторные AVX-инструкции.

Comment on lines +60 to +67
BuildMI(MBB, it, dlDef, TII->get(scalarToAVX[opc1]), tmp)
.addReg(defMI->getOperand(1).getReg())
.addReg(defMI->getOperand(2).getReg());

BuildMI(MBB, it, dlUse, TII->get(scalarToAVX[opc2]),
useMI.getOperand(0).getReg())
.addReg(tmp)
.addReg(useMI.getOperand(2).getReg());
Copy link

Choose a reason for hiding this comment

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

Technically, this is not a fusing. This is the same as tryUpgradeSingle, but for two dependent instructions.
Could you please select any Boolean algebra rule and apply for optimization here?

Comment on lines +3 to +10


# Source files
# test.cpp

# include <emmintrin.h>
# include <immintrin.h>

Choose a reason for hiding this comment

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

Suggested change
# Source files
# test.cpp
# include <emmintrin.h>
# include <immintrin.h>

class AVXLogicCombinerPass : public MachineFunctionPass {
const X86InstrInfo *TII = nullptr;
MachineRegisterInfo *RegInfo = nullptr;
DenseMap<unsigned, unsigned> scalarToAVX;

Choose a reason for hiding this comment

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

I guess you can use static const DenseMap<unsigned, unsigned> scalarToAVX = { ... }

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.

3 participants