Add pass to transform vec3 to vec4 (#781)
This is done only if a bitcast of a vec3 is detected.
It can also be forced using the '-vec3-to-vec4' option.
exceptions:
- internal spirv global variables are often vec3 corresponding to the
3 dimensions. Those are not transformed.
- builtins: some of them are safe to use with vec4 instead of vec3,
but not all of them (OpCopyMemory, OpAny, OpAll, etc)
- packed structs are not lowered
No regression on the OpenCL CTS + 27 new tests passed
Fixes #679
diff --git a/lib/Compiler.cpp b/lib/Compiler.cpp
index 804de1c..d3be208 100644
--- a/lib/Compiler.cpp
+++ b/lib/Compiler.cpp
@@ -662,6 +662,8 @@
}
pm->add(clspv::createReplaceOpenCLBuiltinPass());
+ pm->add(clspv::createThreeElementVectorLoweringPass());
+
// Lower longer vectors when requested. Note that this pass depends on
// ReplaceOpenCLBuiltinPass and expects DeadCodeEliminationPass to be run
// afterwards.