Alan Baker [Tue, 13 Mar 2018 16:02:29 +0000 (12:02 -0400)]
Fixes #1407. Removing assertion against void pointer
Added test
Alan Baker [Tue, 13 Mar 2018 17:48:48 +0000 (13:48 -0400)]
Fixes #1404. Don't DCE workgroup size
Added test.
Greg Fischer [Mon, 12 Mar 2018 22:53:58 +0000 (16:53 -0600)]
Fix InsertFeedingExtract rule when extract remains.
Pierre Moreau [Tue, 20 Feb 2018 18:19:57 +0000 (19:19 +0100)]
Reimplement the DecorationManager
This reimplementation fixes several issues when removing decorations associated
to an ID (partially addresses #1174 and gives tools for fixing #898), as well
as making it easier to remove groups; a few additional tests have been added.
DecorationManager::RemoveDecoration() will still not delete dead decorations it
created, but I do not think it is its job either; given the following input
```
OpCapability Shader
OpCapability Linkage
OpMemoryModel Logical GLSL450
OpDecorate %2 Restrict
%2 = OpDecorationGroup
OpGroupDecorate %2 %1 %3
OpDecorate %4 Invariant
%4 = OpDecorationGroup
OpGroupDecorate %4 %2
%uint = OpTypeInt 32 0
%1 = OpVariable %uint Uniform
%3 = OpVariable %uint Uniform
```
which of the following two outputs would you expect RemoveDecoration(2) to produce:
```
OpCapability Shader
OpCapability Linkage
OpMemoryModel Logical GLSL450
%uint = OpTypeInt 32 0
%1 = OpVariable %uint Uniform
%3 = OpVariable %uint Uniform
```
or
```
OpCapability Shader
OpCapability Linkage
OpMemoryModel Logical GLSL450
OpDecorate %4 Invariant
%4 = OpDecorationGroup
%uint = OpTypeInt 32 0
%1 = OpVariable %uint Uniform
%3 = OpVariable %uint Uniform
```
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/924
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1174
David Neto [Thu, 8 Mar 2018 17:17:52 +0000 (12:17 -0500)]
Remove extension whitelist from some transforms
Remove extension whitelists from transforms that are essentially
combinatorial (and avoiding pointers) or which affect only control flow.
It's very very unlikely an extension will add a new control flow construct.
Remove from:
- dead branch elimination
- dead insertion elimination
- insert extract elimination
- block merge
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1392
Rex Xu [Thu, 8 Mar 2018 13:54:00 +0000 (21:54 +0800)]
Add missing SPV extension strings
David Neto [Wed, 7 Mar 2018 22:13:18 +0000 (17:13 -0500)]
Start v2018.3 development
David Neto [Wed, 7 Mar 2018 22:11:50 +0000 (17:11 -0500)]
Finalize v2018.2
David Neto [Wed, 7 Mar 2018 22:10:13 +0000 (17:10 -0500)]
Update CHANGES
Alan Baker [Wed, 7 Mar 2018 17:58:10 +0000 (12:58 -0500)]
Fixes #1385. Grab correct input to calculate indices.
* Added tests to catch the bug
Andrey Tuganov [Tue, 6 Mar 2018 20:44:05 +0000 (15:44 -0500)]
AMD_gpu_shader_half_float enables float16
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1375
Hardcoded float16 feature enabling if extension
SPV_AMD_gpu_shader_half_float is present.
David Neto [Thu, 1 Mar 2018 21:54:09 +0000 (16:54 -0500)]
Update README for SPIR-V 1.3
David Neto [Fri, 9 Feb 2018 19:29:02 +0000 (14:29 -0500)]
Support SPIR-V 1.3 and Vulkan 1.1
The default target is SPIR-V 1.3.
For example, spirv-as will generate a SPIR-V 1.3 binary by default.
Use command line option "--target-env spv1.0" if you want to make a SPIR-V
1.0 binary or validate against SPIR-V 1.0 rules.
Example:
# Generate a SPIR-V 1.0 binary instead of SPIR-V 1.3
spirv-as --target-env spv1.0 a.spvasm -o a.spv
spirv-as --target-env vulkan1.0 a.spvasm -o a.spv
# Validate as SPIR-V 1.0.
spirv-val --target-env spv1.0 a.spv
# Validate as Vulkan 1.0
spirv-val --target-env vulkan1.0 a.spv
Alan Baker [Mon, 5 Mar 2018 20:02:34 +0000 (15:02 -0500)]
Fixes #1376. Don't handle half folding gracefully.
* Added early returns to folding rules to prevent half attempts
* Added some tests
David Neto [Mon, 5 Mar 2018 18:34:13 +0000 (13:34 -0500)]
Support SPV_GOOGLE_decorate_string and SPV_GOOGLE_hlsl_functionality1
This commit add assembling, disassembling, and basic validation for two
Google extensions to better support HLSL translation.
Steven Perron [Mon, 5 Mar 2018 14:57:41 +0000 (09:57 -0500)]
Avoid generating duplicate names when merging types
The merging types we do not remove other information related to the
types. We simply leave it duplicated, and hope it is removed later.
This is what happens with decorations. They are removed in the next
phase of remove duplicates. However, for OpNames that is not the case.
We end up with two different names for the same id, which does not make
sense.
The solution is to remove the names and decorations for the type being
removed instead of rewriting them to refer to the other type.
Note that it is possible that if the first type does not have a name,
then the types will end up with no name. That is fine because the names
should not have any semantic significance anyway.
The was identified in issue #1372, but this does not fix that issue.
Pierre Moreau [Fri, 2 Mar 2018 21:27:26 +0000 (22:27 +0100)]
Define Disassemble only when Effcee is used in fold_test
David Neto [Fri, 2 Mar 2018 20:24:15 +0000 (15:24 -0500)]
Android.mk: Generate enum mappings from unified1 grammar
Some tokens are only showing up in the unified1 grammar.
So enum string mappings have to be generated from that grammar, not
the grammar from the (deprecated) include/spirv/1.2 grammar.
Example: capabilities FragmentFullyCovered, Float16ImageAMD
David Neto [Fri, 2 Mar 2018 19:11:58 +0000 (14:11 -0500)]
Start v2018.2 development
David Neto [Fri, 2 Mar 2018 19:10:43 +0000 (14:10 -0500)]
Finalize v2018.1
Alan Baker [Fri, 2 Mar 2018 14:19:50 +0000 (09:19 -0500)]
Handles more cases of redundant selects
* Handles OpConstantNull and vector types
* vector selects (except against a null) are converted to vector
shuffles
* Added tests
David Neto [Fri, 2 Mar 2018 19:01:28 +0000 (14:01 -0500)]
Update CHANGES
Alan Baker [Thu, 1 Mar 2018 20:24:41 +0000 (15:24 -0500)]
Fixes #1361. Mark all non-constant global values as varying in CCP
* Also mark function parameters as varying
* Conservatively mark assignment instructions as varying if any input is
varying after attempting to fold
* Added a test to catch this case
Arseny Kapoulkine [Thu, 22 Feb 2018 07:28:45 +0000 (23:28 -0800)]
Vulkan BuiltIn variables can't have Location/Component decorations
As per Vulkan spec, BuiltIn variables can't have Location or Component
decorations. On some drivers, these can lead to driver crashing when
compiling the shader pipeline; for example, NVidia/AMD desktop drivers:
https://github.com/KhronosGroup/glslang/issues/1182.
This change adds validation and tests to catch this.
Alan Baker [Wed, 28 Feb 2018 20:23:19 +0000 (15:23 -0500)]
Fixes #1357. Support null constants better in folding
* getFloatConstantKind() now handles OpConstantNull
* PerformOperation() now handles OpConstantNull for vectors
* Fixed some instances where we would attempt to merge a division by 0
* added tests
GregF [Fri, 23 Feb 2018 22:46:30 +0000 (15:46 -0700)]
Opt: Add constant folding for FToI and IToF
Alan Baker [Tue, 27 Feb 2018 21:19:09 +0000 (16:19 -0500)]
Fixes #1354. Do not merge integer division.
* Removes merging of div with a div or mul for integers
* Updated tests
Steven Perron [Mon, 26 Feb 2018 19:47:11 +0000 (14:47 -0500)]
Add more folding rules for vector shuffle.
Adds rule to fold OpVectorShuffle with constant inputs.
Adds rules to fold OpCompositeExtrac being fed by an OpVectorShuffle.
Victor Lomuller [Tue, 27 Feb 2018 18:34:10 +0000 (18:34 +0000)]
Remove Function::GetBlocks pushed by accident
Steven Perron [Thu, 22 Feb 2018 21:05:37 +0000 (16:05 -0500)]
Remove uses DCEInst and call ADCE
The algorithm used in DCEInst to remove dead code is very slow. It is
fine if you only want to remove a small number of instructions, but, if
you need to remove a large number of instructions, then the algorithm in
ADCE is much faster.
This PR removes the calls to DCEInst in the load-store removal passes
and adds a pass of ADCE afterwards.
A number of different iterations of the order of optimization, and I
believe this is the best I could find.
The results I have on 3 sets of shaders are:
Legalization:
Set 1: 5.39 -> 5.01
Set 2: 13.98 -> 8.38
Set 3: 98.00 -> 96.26
Performance passes:
Set 1: 6.90 -> 5.23
Set 2: 10.11 -> 6.62
Set 3: 253.69 -> 253.74
Size reduction passes:
Set 1: 7.16 -> 7.25
Set 2: 17.17 -> 16.81
Set 3: 112.06 -> 107.71
Note that the third set's compile time is large because of the large
number of basic blocks, not so much because of the number of
instructions. That is why we don't see much gain there.
David Neto [Mon, 12 Feb 2018 15:45:39 +0000 (10:45 -0500)]
Consistently include latest spirv.h header file.
Use indirection through latest_version_spirv.h
Also, when generating enum tables, use the unified1 JSON grammar since
it now has FragmentFullyCoveredEXT but the other JSON grammars don't.
They are starting to fall behind.
Alan Baker [Fri, 16 Feb 2018 21:07:33 +0000 (16:07 -0500)]
Merge arithmetic with non-trivial constant operands
Adding basis of arithmetic merging
* Refactored constant collection in ConstantManager
* New rules:
* consecutive negates
* negate of arithmetic op with a constant
* consecutive muls
* reciprocal of div
* Removed IRContext::CanFoldFloatingPoint
* replaced by Instruction::IsFloatingPointFoldingAllowed
* Fixed some bad tests
* added some header comments
Added PerformIntegerOperation
* minor fixes to constants and tests
* fixed IntMultiplyBy1 to work with 64 bit ints
* added tests for integer mul merging
Adding test for vector integer multiply merging
Adding support for merging integer add and sub through negate
* Added tests
Adding rules to merge mult with preceding divide
* Has a couple tests, but needs more
* Added more comments
Fixed bug in integer division folding
* Will no longer merge through integer division if there would be a
remainder in the division
* Added a bunch more tests
Adding rules to merge divide and multiply through divide
* Improved comments
* Added tests
Adding rules to handle mul or div of a negation
* Added tests
Changes for review
* Early exit if no constants are involved in more functions
* fixed some comments
* removed unused declaration
* clarified some logic
Adding new rules for add and subtract
* Fold adds of adds, subtracts or negates
* Fold subtracts of adds, subtracts or negates
* Added tests
Stephen McGroarty [Tue, 27 Feb 2018 14:22:59 +0000 (14:22 +0000)]
Make IR builder use the type manager for constants
This change makes the IR builder use the type manager to generate
OpTypeInts when creating OpConstants. This avoids dangling references
being stored by the created OpConstants.
Pierre Moreau [Wed, 14 Feb 2018 18:12:05 +0000 (19:12 +0100)]
linker: merge debug annotations from category c)
Fixes: https://github.com/KhronosGroup/SPIRV-Tools/issues/1218
Pierre Moreau [Tue, 13 Feb 2018 21:47:15 +0000 (22:47 +0100)]
linker: Allow modules to be partially linked
Fixes: https://github.com/KhronosGroup/SPIRV-Tools/issues/1144
Pierre Moreau [Tue, 13 Feb 2018 21:04:50 +0000 (22:04 +0100)]
tools/linker: Allow setting --verify-ids on the command line
David Neto [Tue, 27 Feb 2018 16:48:40 +0000 (11:48 -0500)]
Update CHANGES
Victor Lomuller [Mon, 12 Feb 2018 21:42:15 +0000 (21:42 +0000)]
Add loop unswitch pass.
It moves all conditional branching and switch whose conditions are loop
invariant and uniform. Before performing the loop unswitch we check that
the loop does not contain any instruction that would prevent it
(barriers, group instructions etc.).
Stephen McGroarty [Tue, 27 Feb 2018 11:50:08 +0000 (11:50 +0000)]
Unroller support for multiple induction variables
Support for multiple induction variables within a loop and support for
loop condition operands <= and >=.
Steven Perron [Thu, 22 Feb 2018 17:23:21 +0000 (12:23 -0500)]
Clean up variables before sroa
In some shaders there are a lot of very large and deeply nested
structures. This creates a lot of work for scalar replacement. Also,
since commit ca4457b we have been very aggressive as rewriting
variables. This has causes a large increase in compile time in creating
and then deleting the instructions.
To help low the costs, I want to run a cleanup of some of the easy loads
and stores to remove. This reduces the number of symbols sroa has to
work on. It also reduces the amount of code the simplifier has to
simplify because it was not generated by sroa.
To confirm the improvement, I ran numbers on three different sets of
shaders:
Time to run --legalize-hlsl:
Set #1: 55.89s -> 12.0s
Set #2: 1m44s -> 1m40.5s
Set #3: 6.8s -> 5.7s
Time to run -O
Set #1: 18.8s -> 10.9s
Set #2: 5m44s -> 4m17s
Set #3: 7.8s -> 7.8s
Contributes to #1328.
Steven Perron [Wed, 21 Feb 2018 19:35:10 +0000 (14:35 -0500)]
Preserve analysies in the simplification pass
Fixes a bug at the same time. In `UpdateDefUse`, if the definition
already exists, we are not suppose to analyse it again. When you do
the entries for the definition are deleted, and we don't want that.
The check for this was wrong.
Lei Zhang [Thu, 22 Feb 2018 20:16:01 +0000 (15:16 -0500)]
Appveyor: remove VS2015 configuration to reduce build time
We already have VS2013 and VS2017, which should be good guards.
GregF [Wed, 21 Feb 2018 23:43:33 +0000 (16:43 -0700)]
Opt: Check for side-effects in DCEInst()
This function now checks for side-effects before adding operand
instructions to the dead instruction work list.
Because this fix puts more pressure on IsCombinatorInstruction() to
be correct, this commit adds all OpConstant* and OpType* instructions
to combinator_ops_ set.
Fixes #1341.
Alan Baker [Wed, 21 Feb 2018 13:51:21 +0000 (08:51 -0500)]
Fixes #1338. Handle OpConstantNull in branch/switch conditions
* No longer assume the branch/switch condition must be bool or int
constants (respectively)
* Added a couple unit tests for each case
Steven Perron [Tue, 20 Feb 2018 16:24:08 +0000 (11:24 -0500)]
Reduce instruction create and deletion during inlining.
When inlining a function call the instructions in the same basic block
as the call get cloned. The clone is added to the set of new blocks
containing the inlined code, and the original instructions are deleted.
This PR will change this so that we simply move the instructions to the
new blocks. This saves on the creation and deletion of the
instructions.
Contributes to #1328.
Steven Perron [Tue, 20 Feb 2018 23:24:06 +0000 (18:24 -0500)]
Add Insert-extract elimination back into legalization passes.
Fixes #1326.
Arseny Kapoulkine [Sat, 17 Feb 2018 19:55:54 +0000 (11:55 -0800)]
Add folding for redundant add/sub/mul/div/mix operations
This change implements instruction folding for arithmetic operations
that are redundant, specifically:
x + 0 = 0 + x = x
x - 0 = x
0 - x = -x
x * 0 = 0 * x = 0
x * 1 = 1 * x = x
0 / x = 0
x / 1 = x
mix(a, b, 0) = a
mix(a, b, 1) = b
Cache ExtInst import id in feature manager
This allows us to avoid string lookups during optimization; for now we
just cache GLSL std450 import id but I can imagine caching more sets as
they become utilized by the optimizer.
Add tests for add/sub/mul/div/mix folding
The tests cover scalar float/double cases, and some vector cases.
Since most of the code for floating point folding is shared, the tests
for vector folding are not as exhaustive as scalar.
To test sub->negate folding I had to implement a custom fixture.
Steven Perron [Tue, 20 Feb 2018 23:20:19 +0000 (18:20 -0500)]
Revert "Preserve analysies in the simplification pass"
This reverts commit
ec3bbf093e686964d464e3a7c70e691d98ed82c1.
Steven Perron [Tue, 20 Feb 2018 16:46:57 +0000 (11:46 -0500)]
Preserve analysies in the simplification pass
Building the def-use chains is very expensive, so we do not want to
invalidate them it if is not necessary. At the moment, it seems like
most optimizatoins are good at not invalidating the def-use chains, but
simplification does.
This PR get the simlification pass to keep the analysies valid.
Contributes to #1328.
Diego Novillo [Sat, 17 Feb 2018 00:12:50 +0000 (19:12 -0500)]
Speed up Phi insertion.
On some shader code we have in our testsuite, Phi insertion is showing
massive compile time slowdowns, particularly during destruction. The
specific shader I was looking at has about 600 variables to keep track
of and around 3200 basic blocks. The algorithm is currently O(var x
blocks), which means maps with around 2M entries. This was taking about
8 minutes of compile time.
This patch changes the tracking of stored variables to be more sparse.
Instead of having every basic block contain all the tracked variables in
the map, they now have only the variables actually stored in that block.
This speeds up deallocation, which brings down compile time to about
1m20s.
Note that this is not the definite fix for this. I will re-write Phi
insertion to use a standard SSA rewriting algorithm
(https://github.com/KhronosGroup/SPIRV-Tools/issues/893).
This contributes to
https://github.com/KhronosGroup/SPIRV-Tools/issues/1328.
Lei Zhang [Wed, 14 Feb 2018 16:13:34 +0000 (11:13 -0500)]
Travis: require MacOS to build and test again
Steven Perron [Mon, 19 Feb 2018 01:58:05 +0000 (20:58 -0500)]
Fix folding insert feeding extract
I mixed up two cases when folding an OpCompositeExtract that is feed by
and OpCompositeInsert. The specific cases are demonstracted in the new
test. I mixed up the conditions for the cases, and treated one like the
other.
Fixes #1323.
Alan Baker [Wed, 14 Feb 2018 21:56:43 +0000 (16:56 -0500)]
Fixes #1300. Adding checks for bad CCP transitions and unsettled values
* Now track propagation status and assert on bad statuses
* Added helper methods to access instruction propagation status
* Modified the phi meet operator to properly reflect the paper it is
based on
* Modified SSA edge addition so that all edge are added, but only on
state changes
* Fixed a bug in instruction simulation where interesting conditional
branches would not mark the interesting edge as executed
* Added a test to catch this bug
* Added an ostream operator for SSAPropagator::PropStatus
Andrew Woloszyn [Fri, 16 Feb 2018 15:19:36 +0000 (10:19 -0500)]
Removed warnings from hex_float.h
Bitcasting FloatProxy<->uint_type was hitting a warning
with g++8.0.1. Replace bitcasts with new casting traits for FloatProxy.
Steven Perron [Thu, 15 Feb 2018 17:14:39 +0000 (12:14 -0500)]
Make better use of simplification pass
The simplification pass works better after all of the dead branches are
removed. So swapping them around in the legalization passes. Also
adding the simplification pass to performance passes right after dead
branch elimination.
Added CCP to the legalization passes so we can propagate the constants
into the branchs, and remove as many branches a possible. CCP is
designed to still get opportunities even if the branches are dead, so it
is a good place for it.
Fixes #1118
Arseny Kapoulkine [Thu, 15 Feb 2018 06:13:25 +0000 (22:13 -0800)]
Add constant folding rules for floating-point comparison
This change handles all 6 regular comparison types in two variations,
ordered (true if values are ordered *and* comparison is true) and
unordered (true if values are unordered *or* comparison is true).
Ordered comparison matches the default floating-point behavior on host
but we use std::isnan to check ordering explicitly anyway.
This change also slightly reworks the floating-point folding support
code to make it possible to define a folding operation that returns
boolean instead of floating point.
These tests exhaustively test ordered/unordered comparisons for
float/double.
Since for NaN inputs the comparison result doesn't depend on the
comparison function, we just test == and !=; NaN inputs result in true
unordered comparisons and false ordered comparisons.
Arseny Kapoulkine [Thu, 15 Feb 2018 20:27:38 +0000 (12:27 -0800)]
Remove constants from constant manager in KillInst
Registering a constant in constant manager establishes a relation
between instruction that defined it and constant object. On complex
shaders this could result in the constant definition getting removed as
part of one of the DCE pass, and a subsequent simplification pass trying
to use the defining instruction for the constant.
To fix this, we now remove associated constant entries from constant
manager when killing constant instructions; the constant object is still
registered and can be remapped to a new instruction later.
GetDefiningInstruction shouldn't ever return nullptr after this change
so add an assertion to check for that.
Steven Perron [Wed, 14 Feb 2018 02:08:43 +0000 (21:08 -0500)]
Simplify OpPhi instructions referencing unreachable continues
In dead branch elimination, we already recognize unreachable continue
blocks, and update OpPhi instruction accordingly. This change adds an
extra check: if the head block has exactly 1 other incoming edge, then
replace the OpPhi with the value from that edge.
Fixes #1314.
Steven Perron [Thu, 15 Feb 2018 15:41:01 +0000 (10:41 -0500)]
Get CCP to use the constant floating point rules.
Fixes #1311
Lei Zhang [Fri, 16 Feb 2018 00:40:47 +0000 (19:40 -0500)]
SubgroupBallotKHR can enable SubgroupSize & SubgroupLocalInvocationId
Nerijus Baliūnas [Wed, 14 Feb 2018 19:06:53 +0000 (21:06 +0200)]
fix typo
David Neto [Wed, 14 Feb 2018 23:27:22 +0000 (18:27 -0500)]
Invoke cmake via CMAKE_COMMAND variable
Need to do this in case cmake is not on the path.
This should fix the Android NDK build, as in when building the NDK
itself.
Lei Zhang [Thu, 15 Feb 2018 15:19:15 +0000 (10:19 -0500)]
Avoid using static unordered_map (#1304)
unordered_map is not POD. Using it as static may cause problems
when operator new() and operator delete() is customized.
Also changed some function signatures to use const char* instead
of std::string, which will give caller the flexibility to avoid
creating a std::string.
Arseny Kapoulkine [Thu, 15 Feb 2018 04:45:36 +0000 (20:45 -0800)]
Add folding of redundant OpSelect insns
We can fold OpSelect into one of the operands in two cases:
- condition is constant
- both results are the same
Even if the original shader doesn't have either of these, if-conversion
pass sometimes ends up generating instructions like
%7127 = OpSelect %int %3220 %7058 %7058
And this optimization cleans them up.
Steven Perron [Tue, 13 Feb 2018 04:28:38 +0000 (23:28 -0500)]
Add id to name map
Adding a map from an id to it set of OpName and OpMemberName
instructions. This will be used in KillNameAndDecorates to kill the
names for the ids that are being removed.
In my test, the compile time for 50 shaders went from 1m57s to 55s.
This was on linux using the release build.
Fixes #1290.
Steven Perron [Fri, 9 Feb 2018 18:37:26 +0000 (13:37 -0500)]
Fold binary floating point operators.
Adds the floating rules for FAdd, FDiv, FMul, and FSub.
Contributes to #1164.
Stephen McGroarty [Wed, 14 Feb 2018 17:03:12 +0000 (17:03 +0000)]
Initial support for loop unrolling.
This patch adds initial support for loop unrolling in the form of a
series of utility classes which perform the unrolling. The pass can
be run with the command spirv-opt --loop-unroll. This will unroll
loops within the module which have the unroll hint set. The unroller
imposes a number of requirements on the loops it can unroll. These are
documented in the comments for the LoopUtils::CanPerformUnroll method in
loop_utils.h. Some of the restrictions will be lifted in future patches.
Alan Baker [Wed, 14 Feb 2018 14:39:11 +0000 (09:39 -0500)]
Fixes #1295. Mark undef values as varying in ccp.
* Undef now marked as varying in ccp
* this prevents incorrect meet operations since phis were always not
interesting
* added a test to catch the bug
Diego Novillo [Mon, 12 Feb 2018 18:21:48 +0000 (13:21 -0500)]
Cleanup. Use proper #include guard. NFC.
Steven Perron [Sat, 10 Feb 2018 01:33:06 +0000 (20:33 -0500)]
Avoid using the def-use manager during inlining.
There seems to only be a single location where the def-use manager is
used. It is to get information about a type. We can do that with the
type manager instead.
Fixes #1285
Arseny Kapoulkine [Sat, 10 Feb 2018 01:57:29 +0000 (17:57 -0800)]
Fix spirv.h include to rely on include paths
This is important when SPIRV-Headers are not checked out to external/
folder and mirrors other places in the code where spirv.h is included.
Steven Perron [Thu, 8 Feb 2018 15:59:03 +0000 (10:59 -0500)]
Add folding of OpCompositeExtract and OpConstantComposite constant instructions.
Create files for constant folding rules.
Add the rules for OpConstantComposite and OpCompositeExtract.
David Neto [Thu, 8 Feb 2018 17:05:40 +0000 (12:05 -0500)]
Fix generation of Vim syntax file
Józef Kucia [Fri, 9 Feb 2018 11:30:08 +0000 (12:30 +0100)]
Do not hardcode libdir and includedir in pkg config files
Steven Perron [Thu, 8 Feb 2018 16:03:48 +0000 (11:03 -0500)]
Add header files missing from CMakeLists.txt
Alexander Johnston [Mon, 29 Jan 2018 10:39:55 +0000 (10:39 +0000)]
Loop invariant code motion initial implementation
GregF [Wed, 7 Feb 2018 02:54:58 +0000 (19:54 -0700)]
SROA: Do replacement on structs with no partial references.
Steven Perron [Fri, 2 Feb 2018 16:55:05 +0000 (11:55 -0500)]
Make use of the instruction folder.
Implementation of the simplification pass.
- Create pass that calls the instruction folder on each instruction and
propagate instructions that fold to a copy. This will do copy
propagation as well.
- Did not use the propagator engine because I want to modify the instruction
as we go along.
- Change folding to not allocate new instructions, but make changes in
place. This change had a big impact on compile time.
- Add simplification pass to the legalization passes in place of
insert-extract elimination.
- Added test cases for new folding rules.
- Added tests for the simplification pass
- Added a method to the CFG to apply a function to the basic blocks in
reverse post order.
Contributes to #1164.
Andrey Tuganov [Tue, 6 Feb 2018 20:25:03 +0000 (15:25 -0500)]
Disable check which fails Vulkan CTS
Andrey Tuganov [Tue, 6 Feb 2018 17:10:11 +0000 (12:10 -0500)]
Add Vulkan-specific validation rules for atomics
Added atomic instructions validation rules from
https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#spirvenv-module-validation
Józef Kucia [Fri, 2 Feb 2018 22:37:14 +0000 (23:37 +0100)]
Build SPIRV-Tools as shared library
Add pkg-config file for shared libraries
Properly build SPIRV-Tools DLL
Test C interface with shared library
Set PATH to shared library file for c_interface_shared test
Otherwise, the test won't find SPIRV-Tools-shared.dll.
Do not use private functions when testing with shared library
Make all symbols hidden by default for shared library target
David Neto [Tue, 6 Feb 2018 16:13:39 +0000 (08:13 -0800)]
Enable Visual Studio 2013 again
Disable use of Effcee and RE2 with MSVC compilers older than Visual
Studio 2015 since RE2 doesn't support them.
David Neto [Tue, 6 Feb 2018 17:06:26 +0000 (12:06 -0500)]
Fix test inclusion when Effcee is absent
David Neto [Tue, 6 Feb 2018 16:47:44 +0000 (11:47 -0500)]
Update CHANGES
Alan Baker [Mon, 5 Feb 2018 14:47:05 +0000 (09:47 -0500)]
Registering a type now rebuilds it out of memory owned by the manager.
* Added TypeManager::RebuildType
* rebuilds the type and its constituent types in terms of memory owned
by the manager.
* Used by TypeManager::RegisterType to properly allocate memory
* Adding an unit test to expose the issue
* Added some tests to provide coverage of RebuildType
* Added an accessor to the target pointer for a forward pointer
GregF [Fri, 2 Feb 2018 23:57:39 +0000 (16:57 -0700)]
ADCE: Fix combinator initialization
The combinator initialization was only looking at the capabilities
in the shader and not the inferred capabilities. Geometry and tessellation
shaders were not setting the Shader capability which is inferred. So the
combinator set was not initialized correctly causing problems for ADCE.
David Neto [Mon, 5 Feb 2018 15:56:45 +0000 (07:56 -0800)]
VS2013: LoopDescriptor LoopContainerType can't contain unique_ptr
The loop descriptor must explicitly manage the storage for contained
Loop objects.
Fixes #1262
Andrey Tuganov [Wed, 31 Jan 2018 21:29:54 +0000 (16:29 -0500)]
Add barrier instructions validation pass
David Neto [Fri, 2 Feb 2018 15:28:52 +0000 (10:28 -0500)]
Avoid vector copies in range-for loops in opt/types.cpp
Also be more explicit about iterated types in other range-for loops.
David Neto [Fri, 2 Feb 2018 22:17:42 +0000 (14:17 -0800)]
Disambiguate between const and nonconst ForEachSuccessorLabel
This helps VisualStudio 2013 compile the code.
Contributes to #1262
Steven Perron [Wed, 24 Jan 2018 18:26:33 +0000 (13:26 -0500)]
Add general folding infrastructure.
Create the folding engine that will
1) attempt to fold an instruction.
2) iterates on the folding so small folding rules can be easily combined.
3) insert new instructions when needed.
I've added the minimum number of rules needed to test the features above.
David Neto [Fri, 2 Feb 2018 16:27:07 +0000 (11:27 -0500)]
Start v2018.1-dev
David Neto [Fri, 2 Feb 2018 16:25:58 +0000 (11:25 -0500)]
Finalize v2018.0
David Neto [Fri, 2 Feb 2018 16:23:33 +0000 (11:23 -0500)]
Update CHANGES
Alan Baker [Wed, 31 Jan 2018 15:40:33 +0000 (10:40 -0500)]
Reordering performance passes ordering to produce better opts
* Moved initial insert/extract passes later to cover more opportunities
* Added an extra set of passes to clean up opportunities exposed later
in the pipeline
Victor Lomuller [Fri, 26 Jan 2018 12:07:10 +0000 (12:07 +0000)]
Add LoopUtils class to gather some loop transformation support.
This patch adds LoopUtils class to handle some loop related transformations. For now it has 2 transformations that simplifies other transformations such as loop unroll or unswitch:
- Dedicate exit blocks: this ensure that all exit basic block
(out-of-loop basic blocks that have a predecessor in the loop)
have all their predecessors in the loop;
- Loop Closed SSA (LCSSA): this ensure that all definitions in a loop are used inside the loop
or in a phi instruction in an exit basic block.
It also adds the following capabilities:
- Loop::IsLCSSA to test if the loop is in a LCSSA form
- Loop::GetOrCreatePreHeaderBlock that can build a loop preheader if required;
- New methods to allow on the fly updates of the loop descriptors.
- New methods to allow on the fly updates of the CFG analysis.
- Instruction::SetOperand to allow expression of the index relative to Instruction::NumOperands (to be compatible with the index returned by DefUseManager::ForEachUse)
Steven Perron [Tue, 30 Jan 2018 16:24:03 +0000 (11:24 -0500)]
Add pass to reaplce invalid opcodes
Creates a pass that will remove instructions that are invalid for the
current shader stage. For the instruction to be considered for replacement
1) The opcode must be valid for a shader modules.
2) The opcode must be invalid for the current shader stage.
3) All entry points to the module must be for the same shader stage.
4) The function containing the instruction must be reachable from an entry point.
Fixes #1247.
Andrey Tuganov [Tue, 9 Jan 2018 15:58:22 +0000 (10:58 -0500)]
Added OpenCL ExtInst validation rules
Jeremy Hayes [Thu, 25 Jan 2018 23:32:01 +0000 (16:32 -0700)]
Add adjacency validation pass
Validate OpPhi predecessors.
Validate OpLoopMerge successors.
Validate OpSelectionMerge successors.
Fix collateral damage to existing tests.
Remove ValidateIdWithMessage.OpSampledImageUsedInOpPhiBad.
Andrey Tuganov [Wed, 31 Jan 2018 21:59:55 +0000 (16:59 -0500)]
Fixed harmless uninit var warning