Skip to content

spirv-fuzz: Transformation to adjust language operators #3440

@Vasniktel

Description

@Vasniktel

Overview

The idea behind this transformation is to introduce new instructions that don’t change the meaning of mathematical expressions. It can be illustrated as follows:

a => a + 0,
a => a * 1,
a => true && a
a => false || a
a > b => !(a <= b)
a == b => !(a != b)
3 => int(float(3))

etc…
Result of this transformation can later be used in other transformations to, for example, replace the constant (true, false, 0, 1) with a result of some expression that always evaluates to that constant.

Implementation

In fuzzer pass, we can simply iterate over all types and their usages in the module and for each usage randomly decide whether we want to add one of those instructions. For example, if we have an id of floating-point vector type, we can add an OpVectorTimesScalar instruction to multiply it by 1 or OpFAdd instruction to add a vector of zeros to it. These are type-dependent transformations. We also have instruction-dependent transformations (e.g. a > b => !(a <= b)). We might want to separate these into different transformations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions