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 18:54:01 -0600
commitfa4210a9a0729eba04593b7df7b701e2b243de39 (patch)
tree978e27e5336f397cf21a2c0bfe31d6b1ac6c249b /llvm/tools/llvm-reduce/DeltaManager.cpp
parent1b2bda8d1a82b0ffc49eb485824fca93db1b0aac (diff)
downloadllvm-fa4210a9a0729eba04593b7df7b701e2b243de39.zip
llvm-fa4210a9a0729eba04593b7df7b701e2b243de39.tar.gz
llvm-fa4210a9a0729eba04593b7df7b701e2b243de39.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. 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)