// Copyright (c) 2018 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef SOURCE_OPT_COPY_PROP_ARRAYS_H_ #define SOURCE_OPT_COPY_PROP_ARRAYS_H_ #include <memory> #include <vector> #include "source/opt/mem_pass.h" namespace spvtools { namespace opt { // This pass implements a simple array copy propagation. It does not do a full // array data flow. It looks for simple cases that meet the following // conditions: // // 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, so we give up if we see any instruction that might be hard to // update. class CopyPropagateArrays : public MemPass { … }; } // namespace opt } // namespace spvtools #endif // SOURCE_OPT_COPY_PROP_ARRAYS_H_