Commit Graph

9 Commits

Author SHA1 Message Date
Paul Thomson
3335c61147
reduce: Add two branch reduction passes (#2507)
* Fix #2320. `conditional_branch_to_simple_conditional_branch` reduction pass changes conditional branches so both targets point to the same block id (creating a "simple" conditional branch).
* Fix #2501. `simple_conditional_branch_to_branch` reduction pass changes "simple" conditional branches to branches. 
* Fix #2503. `conditional_branch_to_simple_conditional_branch` proper handling of back-edges.
2019-04-15 19:54:36 +01:00
Paul Thomson
d90aae9a5a
reduce: miscellaneous fixes (#2494)
* Fix .gitignore 
* Add missing reduction pass: RemoveBlockReductionOpportunityFinder 
* Add DumpShader functions in test_reduce for debugging 
* Add DumpShader functions in spirv-reduce for debugging 
* Fix include style 
* Don't use "using namespace"
2019-04-08 19:37:17 +01:00
Paul Thomson
e2ddb9371e
reduce: add remove_selection_reduction_opportunity (#2485)
Fix #2484
2019-04-02 16:50:15 +01:00
Paul Thomson
7d1b176c1d
Improve reducer algorithm and other changes (#2472)
Fix #2475. Fix #2476. 

* Improve reducer algorithm: shrink granularity, remove an early return, no lazy initialization, notify pass if binary is interesting, add comments.
* Add fail-on-validation-error option to fail a reduction if an invalid state is reached; useful for tests.
* Set fail-on-validation-error in tests.
* Improve some documentation comments.
* Add Reducer::AddDefaultReductionPasses so tests (and other library consumers) can add the default reduction passes.
* Add CLIMessageConsumer in test_reduce so we can see messages for tricky tests.
* Remove test RemoveUnreferencedInstructionReductionPassTest_ApplyReduction because it was indirectly testing the reduction algorithm, not the RemoveUnreferencedInstruction pass.
* Tweak tests where needed.
2019-03-26 13:22:31 +00:00
Paul Thomson
2d52cbee49
Add some val options to reduce (#2401)
Fix #2396 

* Check that initial state is valid. Add kInitialStateInvalid. 
* Fix RemoveOpnameAndRemoveUnreferenced test; turns out the original shader is invalid, but we never notice because we don't check this and the reduced shader is valid; fix original shader. Assert reduction status is kComplete.
* Always check return value from `Reducer::Run`.
* Change Reducer::Run to *not* immediately copy the input binary.
2019-03-21 14:28:06 +00:00
Alastair Donaldson
86d0d9be25 Refactored reducer so that the 'finding' functionality of a reduction pass are separated from the generic functionality for tracking progress of a pass. With this change, we now have a ReductionOpportunityFinder abstract class, with many subclasses for each type of reduction, and just one ReductionPass class, which has an associated finder. (#2321)
Sounds good.
2019-01-23 17:07:58 -05:00
Alastair Donaldson
1cba9942bd Validate during reduction (#2194)
* Run validator during reduction.

* Added functionality to validate modules after each reduction step, and some tests to check this is working.  Also fixed an issue where reduction passes were not guaranteed to be executed at their minimum granularities.
2018-12-12 09:06:13 -05:00
dan sinclair
78c951b3f6
Add newline at end of file (#2098) 2018-11-22 14:35:40 -05:00
Alastair Donaldson
f3acb955c2 Initial commit for spirv-reduce. (#2056)
Creates a new tool that can be used to reduce failing testcases, similar to creduce.
2018-11-21 14:03:09 -05:00