vshr GPU Virtual ISA NVIDIA

vshr Scalar Video Instructions

// 32-bit scalar operation, with optional secondary operation
vshr.dtype.atype.u32{.sat}.mode d, a{.asel}, b{.bsel};

vshl Shift a left by unsigned amount in b with optional saturate, and optional secondary arithmetic operation or subword data merge.

Encoding

PTX is a virtual instruction set. It has no single, stable native binary encoding - the compiler lowers this instruction to different native machine code depending on the selected NVIDIA target architecture (compute capability). This page intentionally shows no bit-diagram; see the target/version requirements below for what governs how this instruction compiles.
PTX ISA Version Introduced PTX ISA 2.0
Minimum Target sm_20

Syntax Forms

One mnemonic covers many type / state-space / scope / modifier combinations - each row below is an independently valid form.

Syntax Data Types State Space(s) Modifiers Min. Target Description
// 32-bit scalar operation, with optional secondary operation vshr.dtype.atype.u32{.sat}.mode d, a{.asel}, b{.bsel}; sm_20 vshl Shift a left by unsigned amount in b with optional saturate, and optional secondary arithmetic operation or subword data merge. Left shift fills with zero. (see the official PTX ISA docs for the full description)

Operands

At a Glance

Data Types -

Related

More in Scalar Video Instructions

Reference

NVIDIA PTX ISA

Description

vshl Shift a left by unsigned amount in b with optional saturate, and optional secondary arithmetic operation or subword data merge. Left shift fills with zero. vshr Shift a right by unsigned amount in b with optional saturate, and optional secondary arithmetic operation or subword data merge. Signed shift fills with the sign bit, unsigned shift fills with zero.

Semantics

// extract byte/half-word/word and sign- or zero-extend // based on source operand type ta = partSelectSignExtend( a,atype, asel ); tb = partSelectSignExtend( b, .u32, bsel ); if ( mode == .clamp && tb > 32 ) tb = 32; if ( mode == .wrap ) tb = tb & 0x1f; switch ( vop ){ case vshl: tmp = ta << tb; case vshr: tmp = ta >> tb; } // saturate, taking into account destination type and merge operations tmp = optSaturate( tmp, sat, isSigned(dtype), dsel ); d = optSecondaryOp( op2, tmp, c ); // optional secondary operation d = optMerge( dsel, tmp, c ); // optional merge with c operand

Examples

vshl.s32.u32.u32.clamp  r1, r2, r3;
vshr.u32.u32.u32.wrap   r1, r2, r3.h1;

Reproduced from NVIDIA's official PTX ISA documentation for technical accuracy.

Sources