Skip to content

spirv-fuzz: Transformation that adds synonyms for OpAny and OpAll #3768

@andreperezmaselco

Description

@andreperezmaselco

The OpAny and OpAll instructions operate on vectors. A transformation could extract the vector components and then apply the corresponding logical operations on them to get the same result as OpAny and OpAll. The following is an example.

Reference shader Variant shader
        
      OpCapability Shader
 %1 = OpExtInstImport "GLSL.std.450"
      OpMemoryModel Logical GLSL450
      OpEntryPoint Vertex %9 "main"
        
; Types %2 = OpTypeBool %3 = OpTypeVector %2 2 %4 = OpTypeVoid %5 = OpTypeFunction %4
; Constants %6 = OpConstantTrue %2 %7 = OpConstantFalse %2 %8 = OpConstantComposite %3 %6 %7
; main function %9 = OpFunction %4 None %5 %10 = OpLabel %11 = OpAny %2 %8 OpReturn OpFunctionEnd
        
      OpCapability Shader
 %1 = OpExtInstImport "GLSL.std.450"
      OpMemoryModel Logical GLSL450
      OpEntryPoint Vertex %9 "main"
        
; Types %2 = OpTypeBool %3 = OpTypeVector %2 2 %4 = OpTypeVoid %5 = OpTypeFunction %4
; Constants %6 = OpConstantTrue %2 %7 = OpConstantFalse %2 %8 = OpConstantComposite %3 %6 %7
; main function %9 = OpFunction %4 None %5 %10 = OpLabel %12 = OpCompositeExtract %2 %8 0 %13 = OpCompositeExtract %2 %8 1 %11 = OpLogicalOr %2 %12 %13 OpReturn OpFunctionEnd

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions