Encoding:

MSA

011110

000

df

wt

ws

wd

3R

010101

6

3

2

5

5

5

6

Format:

VSHF.df 

Vector Data Preserving Shuffle

VSHF.B wd,ws,wt

MSA

Vector Data Preserving Shuffle

VSHF.H wd,ws,wt

MSA

Vector Data Preserving Shuffle

VSHF.W wd,ws,wt

MSA

Vector Data Preserving Shuffle

VSHF.D wd,ws,wt

MSA

Vector Data Preserving Shuffle

Purpose:

Vector Data Preserving Shuffle

Vector elements selective copy based on the control vector preserving the input data vectors.

Description:

wd = vector_shuffle(control(wd), ws, wt)

concatenation of vectors ws and wt into

The vector shuffle instructions selectively copy data elements from the vector wd based on the corresponding control element in wd.

The least significant 6 bits in wd control elements modulo the number of elements in the concatenated vectors ws, wt specify the index of the source element. If bit 6 or bit 7 is 1, there will be no copy, but rather the destination element is set to 0.

The operands and results are values in integer data format df.

Restrictions:

No data-dependent exceptions are possible.

Operation:

VSHF.B
   v = WR[ws] || WR[wt]
   for i in 0 .. WRLEN/8-1
      k = WR[wd]8i+5..8i mod (WRLEN/4)
      if WR[wd]8i+7..8i+6 != 0 then
         WR[wd]8i+7..8i = 0
      else
         WR[wd]8i+7..8i = v8k+7..8k
      endif
   endfor
VSHF.H
   v = WR[ws] || WR[wt]
   for i in 0 .. WRLEN/16-1
      k = WR[wd]16i+5..16i mod (WRLEN/8)
      if WR[wd]16i+7..16i+6 !=0 then
         WR[wd]16i+15..16i = 0
      else
         WR[wd]16i+15..16i = v16k+15..16k
      endif
   endfor
VSHF.W
   v = WR[ws] || WR[wt]
   for i in 0 .. WRLEN/32-1
      k = WR[wd]32i+5..32i mod (WRLEN/16)
      if WR[wd]32i+7..32i+6 != 0 then
         WR[wd]32i+31..32i = 0
      else
         WR[wd]32i+31..32i = v32k+31..32k
      endif
   endfor
VSHF.D
   v = WR[ws] || WR[wt]
   for i in 0 .. WRLEN/64-1
      k = WR[wd]64i+5..64i mod (WRLEN/32)
      if WR[wd]64i+7..64i+6 != 0 then
         WR[wd]64i+63..64i = 0
      else
         WR[wd]64i+63..64i = v64k+63..64k
      endif
   endfor

Exceptions:

Reserved Instruction Exception, MSA Disabled Exception.