[PATCH] D111818: [llvm-reduce] Introduce operands-skip pass.
Michael Kruse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 14 09:48:12 PDT 2021
Meinersbur created this revision.
Meinersbur added reviewers: aeubanks, hans, dblaikie, fhahn.
Herald added a subscriber: mgorny.
Meinersbur requested review of this revision.
Herald added a project: LLVM.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D111818
Files:
llvm/test/tools/llvm-reduce/operands-skip.ll
llvm/tools/llvm-reduce/CMakeLists.txt
llvm/tools/llvm-reduce/DeltaManager.cpp
llvm/tools/llvm-reduce/deltas/ReduceOperandsSkip.cpp
llvm/tools/llvm-reduce/deltas/ReduceOperandsSkip.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111818.379741.patch
Type: text/x-patch
Size: 12961 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211014/b86a92e2/attachment.bin>
More information about the llvm-commits
mailing list