-
Notifications
You must be signed in to change notification settings - Fork 59
Kulagin Aleksandr / lab 4 / var 2 #159
Kulagin Aleksandr / lab 4 / var 2 #159
Conversation
mlir/lib/Transforms/lab4/kulagin_aleksandr/KulaginAleksandrFMAPass.cpp
Outdated
Show resolved
Hide resolved
mlir/lib/Transforms/lab4/kulagin_aleksandr/KulaginAleksandrFMAPass.cpp
Outdated
Show resolved
Hide resolved
The code has been refactored and I added requested test case 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 |
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 |
Has features:
d = a - b * c
andd = b * c - a
.fadd
orfsub
operation is not used anywhere else, we can safely delete it.Issues:
-O1
+. With-O0
I cannot bypassstore
operation because I can't catch it withgetDefiningOp
. I can catchload
operation, but it's operand is not a result offadd
. It's a result ofalloca
, so it's useless. I hope it's okay.