Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Soloninko Andrey. Lab 3, opt 1 #118

Merged
merged 7 commits into from
Apr 26, 2024

Conversation

Manymoera
Copy link

Implemented an optimization pass that replaces multiplication and addition operation:
tmp = a * b;
d = tmp + c;
with muladd instruction:
d = muladd(a, b, c);

MBIter != MachineBlock.end(); ++MBIter) {
if (MBIter->getOpcode() != llvm::X86::MULPDrr) {
continue;
} else {
Copy link

Choose a reason for hiding this comment

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

Suggested change
} else {
}


# __m128d foo(__m128d a, __m128d b, __m128d c, __m128d d) {
# __m128d tmp = a * b;
# d = tmp + c;
Copy link

Choose a reason for hiding this comment

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

Could you please provide more tests?
Like:
tmp = ab;
tmp2 = c
d;
tmp3 = tmp + tmp2;

tmp = ab;
tmp2 = c
d;
tmp3 = tmp2 + tmp;
tmp4 = tmp2 + tmp3;

} else {
break;
}
continue;
Copy link

Choose a reason for hiding this comment

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

Suggested change
continue;

llvm::MachineBasicBlock::iterator MulInstr = MBIter;
++MBIter;
while (MBIter != MachineBlock.end()) {
if (MBIter->getOpcode() == llvm::X86::ADDPDrr) {
Copy link

Choose a reason for hiding this comment

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

Suggested change
if (MBIter->getOpcode() == llvm::X86::ADDPDrr) {
if (MBIter->getOpcode() != llvm::X86::ADDPDrr) {
break;
}

@@ -167,6 +167,7 @@ FunctionPass *createX86LoadValueInjectionRetHardeningPass();
FunctionPass *createX86SpeculativeLoadHardeningPass();
FunctionPass *createX86SpeculativeExecutionSideEffectSuppression();
FunctionPass *createX86ArgumentStackSlotPass();
FunctionPass *createX86SoloninkoOptsPass();
Copy link

Choose a reason for hiding this comment

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

Please make a pass as dynamic plugin.

@m-ly4 m-ly4 merged commit a26b6b4 into NN-complr-tech:course-spring-2024 Apr 26, 2024
5 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants