aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSteven Perron <stevenperron@google.com>2018-03-20 23:33:24 -0400
committerSteven Perron <stevenperron@google.com>2018-03-26 14:44:41 -0400
commitc4dc04639904479f4418a86d2d1641514047bbff (patch)
tree1b3c06931b3c4fcc70f422941230062e25b82796 /include
parent0a8b6a96e162d1a1c57968a09f4ff22197ecc258 (diff)
downloadspirv-tools-c4dc04639904479f4418a86d2d1641514047bbff.tar.gz
Copy propagate arrays
The sprir-v generated from HLSL code contain many copyies of very large arrays. Not only are these time consumming, but they also cause problems for drivers because they require too much space. To work around this, we will implement an array copy propagation. Note that we will not implement a complete array data flow analysis in order to implement this. We will be looking for very simple cases: 1) The source must never be stored to. 2) The target must be stored to exactly once. 3) The store to the target must be a store to the entire array, and be a copy of the entire source. 4) All loads of the target must be dominated by the store. The hard part is keeping all of the types correct. We do not want to have to do too large a search to update everything, which may not be possible, do we give up if we see any instruction that might be hard to update. Also in types.h, the element decorations are not stored in an std::map. This change was done so the hashing algorithm for a Struct is consistent. With the std::unordered_map, the traversal order was non-deterministic leading to the same type getting hashed to different values. See |Struct::GetExtraHashWords|. Contributes to #1416.
Diffstat (limited to 'include')
-rw-r--r--include/spirv-tools/optimizer.hpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/spirv-tools/optimizer.hpp b/include/spirv-tools/optimizer.hpp
index b7a511ae..3a03988e 100644
--- a/include/spirv-tools/optimizer.hpp
+++ b/include/spirv-tools/optimizer.hpp
@@ -548,6 +548,10 @@ Optimizer::PassToken CreateLoopUnrollPass(bool fully_unroll, int factor = 0);
// processed (see IsSSATargetVar for details).
Optimizer::PassToken CreateSSARewritePass();
+// Create copy propagate arrays pass.
+// This pass looks to copy propagate memory references for arrays. It looks
+// for specific code patterns to recognize array copies.
+Optimizer::PassToken CreateCopyPropagateArraysPass();
} // namespace spvtools
#endif // SPIRV_TOOLS_OPTIMIZER_HPP_