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

Kulagin Aleksandr / lab 4 / var 2 #159

Merged

Conversation

mahbhlddnhakkh
Copy link

Has features:

  • A support for d = a - b * c and d = b * c - a.
  • If the result of a fadd or fsub operation is not used anywhere else, we can safely delete it.

Issues:

  • Works correctly with -O1+. With -O0 I cannot bypass store operation because I can't catch it with getDefiningOp. I can catch load operation, but it's operand is not a result of fadd. It's a result of alloca, so it's useless. I hope it's okay.

@mahbhlddnhakkh
Copy link
Author

The code has been refactored and I added requested test case f7. The result of this looks good enough for me. Basically:

double c = a * b;
double d = fma(a, b, c);

@mahbhlddnhakkh mahbhlddnhakkh requested a review from m-ly4 May 19, 2024 10:07
@m-ly4
Copy link

m-ly4 commented May 19, 2024

The code has been refactored and I added requested test case f7. The result of this looks good enough for me. Basically:

double c = a * b;
double d = fma(a, b, c);

Well, in "optimized" case we perform 2 multiplications and one addition, while initially there was 1 multiplication and 1 addition. So, I'd prefer to leave the code as is here.

@mahbhlddnhakkh
Copy link
Author

The code has been refactored and I added requested test case f7. The result of this looks good enough for me. Basically:

double c = a * b;
double d = fma(a, b, c);

Well, in "optimized" case we perform 2 multiplications and one addition, while initially there was 1 multiplication and 1 addition. So, I'd prefer to leave the code as is here.

But the initial task was "Write a pass that merges multiplication and addition into a single math.fma". In that case, we don't need to use fma if the result of addition operation is used anywhere else because fma will always just replace fadd. So it means that f6 test should also not expect fma for 'optimization'. Am I correct?

@m-ly4
Copy link

m-ly4 commented May 19, 2024

The code has been refactored and I added requested test case f7. The result of this looks good enough for me. Basically:

double c = a * b;
double d = fma(a, b, c);

Well, in "optimized" case we perform 2 multiplications and one addition, while initially there was 1 multiplication and 1 addition. So, I'd prefer to leave the code as is here.

But the initial task was "Write a pass that merges multiplication and addition into a single math.fma". In that case, we don't need to use fma if the result of addition operation is used anywhere else because fma will always just replace fadd. So it means that f6 test should also not expect fma for 'optimization'. Am I correct?

Strictly speaking, yes, it has small sense if we cannot remove both mul and add operations after replacement. The aim of this replacement is to reduce potential program execution time by replacing two operations with one.

@mahbhlddnhakkh
Copy link
Author

The code has been refactored and I added requested test case f7. The result of this looks good enough for me. Basically:

double c = a * b;
double d = fma(a, b, c);

Well, in "optimized" case we perform 2 multiplications and one addition, while initially there was 1 multiplication and 1 addition. So, I'd prefer to leave the code as is here.

But the initial task was "Write a pass that merges multiplication and addition into a single math.fma". In that case, we don't need to use fma if the result of addition operation is used anywhere else because fma will always just replace fadd. So it means that f6 test should also not expect fma for 'optimization'. Am I correct?

Strictly speaking, yes, it has small sense if we cannot remove both mul and add operations after replacement. The aim of this replacement is to reduce potential program execution time by replacing two operations with one.

Done

@m-ly4 m-ly4 merged commit 901ca41 into NN-complr-tech:course-spring-2024 May 19, 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.

3 participants