aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-reduce/DeltaManager.cpp
diff options
context:
space:
mode:
authorMichael Kruse <llvm-project@meinersbur.de>2021-11-11 18:23:27 -0600
committerMichael Kruse <llvm-project@meinersbur.de>2021-11-11 20:16:34 -0600
commitc15f930e9656dbcbd6384b403ec0fd5e28d350ed (patch)
tree92668d1ec47c7fd1c44ccc1e74947b9bf1283244 /llvm/tools/llvm-reduce/DeltaManager.cpp
parentc7be8b75399c727ec9e1ddc3f81510f284c65155 (diff)
downloadllvm-c15f930e9656dbcbd6384b403ec0fd5e28d350ed.zip
llvm-c15f930e9656dbcbd6384b403ec0fd5e28d350ed.tar.gz
llvm-c15f930e9656dbcbd6384b403ec0fd5e28d350ed.tar.bz2
[llvm-reduce] Introduce operands-skip pass.
Add a new "operands-skip" pass whose goal is to remove instructions in the middle of dependency chains. For instance: ``` %baseptr = alloca i32 %arrayidx = getelementptr i32, i32* %baseptr, i32 %idxprom store i32 42, i32* %arrayidx ``` might be reducible to ``` %baseptr = alloca i32 %arrayidx = getelementptr ... ; now dead, together with the computation of %idxprom store i32 42, i32* %baseptr ``` Other passes would either replace `%baseptr` with undef (operands, instructions) or move it to become a function argument (operands-to-args), both of which might fail the interestingness check. In principle the implementation allows operand replacement with any value or instruction in the function that passes the filter constraints (same type, dominance, "more reduced"), but is limited in this patch to values that are directly or indirectly used to compute the current operand value, motivated by the example above. Additionally, function arguments are added to the candidate set which helps reducing the number of relevant arguments mitigating a concern of too many arguments mentioned in https://reviews.llvm.org/D110274#3025013. Possible future extensions: * Instead of requiring the same type, bitcast/trunc/zext could be automatically inserted for some more flexibility. * If undef is added to the candidate set, "operands-skip"is able to produce any reduction that "operands" can do. Additional candidates might be zero and one, where the "reductive power" classification can prefer one over the other. If undefined behaviour should not be introduced, undef can be removed from the candidate set. Recommit after resolving conflict with D112651 and reusing shouldReduceOperand from D113532. Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D111818
Diffstat (limited to 'llvm/tools/llvm-reduce/DeltaManager.cpp')
-rw-r--r--llvm/tools/llvm-reduce/DeltaManager.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/tools/llvm-reduce/DeltaManager.cpp b/llvm/tools/llvm-reduce/DeltaManager.cpp
index a606502..59edf73 100644
--- a/llvm/tools/llvm-reduce/DeltaManager.cpp
+++ b/llvm/tools/llvm-reduce/DeltaManager.cpp
@@ -30,6 +30,7 @@
#include "deltas/ReduceModuleData.h"
#include "deltas/ReduceOperandBundles.h"
#include "deltas/ReduceOperands.h"
+#include "deltas/ReduceOperandsSkip.h"
#include "deltas/ReduceOperandsToArgs.h"
#include "deltas/ReduceSpecialGlobals.h"
#include "llvm/Support/CommandLine.h"
@@ -58,6 +59,7 @@ static cl::opt<std::string>
DELTA_PASS("operands-one", reduceOperandsOneDeltaPass) \
DELTA_PASS("operands-undef", reduceOperandsUndefDeltaPass) \
DELTA_PASS("operands-to-args", reduceOperandsToArgsDeltaPass) \
+ DELTA_PASS("operands-skip", reduceOperandsSkipDeltaPass) \
DELTA_PASS("operand-bundles", reduceOperandBundesDeltaPass) \
DELTA_PASS("attributes", reduceAttributesDeltaPass) \
DELTA_PASS("module-data", reduceModuleDataDeltaPass)