  Recent research has shown that dynamic zeros in shader programs of gaming
applications can be effectively leveraged with a profile-guided,
code-versioning transform. This transform duplicates code, specializes one path
assuming certain key program operands, called versioning variables, are zero,
and leaves the other path unspecialized. Dynamically, depending on the
versioning variable's value, either the specialized fast path or the default
slow path will execute. Prior work applied this transform manually and showed
promising gains on gaming applications. In this paper, we present AZP, an
automatic compiler approach to perform the above code-versioning transform. Our
framework automatically determines which versioning variables or combinations
of them are profitable, and determines the code region to duplicate and
specialize (called the versioning scope). AZP takes operand zero value
probabilities as input and it then uses classical techniques such as constant
folding and dead-code elimination to determine the most profitable versioning
variables and their versioning scopes. This information is then used to affect
the final transform in a straightforward manner. We demonstrate that AZP is
able to achieve an average speedup of 16.4% for targeted shader programs,
amounting to an average frame-rate speedup of 3.5% across a collection of
modern gaming applications on an NVIDIA GeForce RTX 2080 GPU GPU.
