Changes between Version 5 and Version 6 of ShufflePatternLibrary
 Timestamp:
 Apr 26, 2014, 6:19:21 PM (5 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

ShufflePatternLibrary
v5 v6 4 4 5 5 The LLVM IR contains a very powerful vector operation 6 called [http://llvm.org/docs/LangRef.html#shufflevectorinstruction {{{shufflevector}}}]. Unless the target architecture6 called [http://llvm.org/docs/LangRef.html#shufflevectorinstruction shufflevector]. Unless the target architecture 7 7 supports a similarly powerful operation directly, good 8 8 code generation for {{{shufflevector}}} instructions with arbitrary … … 29 29 we first perform some transformations to put shuffle vectors 30 30 in canonical form. 31 32 ==== An Initial Example ==== 31 33 32 34 For example, consider the following three {{{shufflevector}}} patterns … … 55 57 56 58 59 ==== Canonical Selection from Constant Splats ==== 60 57 61 In general, in discussing canonical forms, we refer to the 58 62 three consecutive arguments of {{{shufflevector}}} as 59 63 vector 1 or {{{v1}}}, vector 2 or {{{v2}}} and {{{mask}}}. 64 65 A constant splat is a constant vector having the same 66 value in every field. When used as a vector, {{{zeroinitializer}}} 67 is a constant splat of the value {{{0}}}. 68 69 Whenever one of the input vectors is a constant splat vector, 70 then the canonical selection mask values for selecting a 71 value from this vector must alwayws specify 72 selection from the first field in the vector. 73 That is, if the size of the input vectors is {{{n}}}, 74 and vector 2 is a constant splat, then the index {{{n}}} 75 is the canonical index for selection from this vector. 76 Conversion to constant indexes in this case is illustrated 77 in the second step of the example above. If vector 1 78 is a constant splat, then the canonical index 79 for selection from this vector is {{{0}}}. 60 80 61 81 ==== Canonical Order of Vectors ==== … … 85 105 2. If one of the vectors is {{{zeroinitializer}}} (or the equivalent constant), and the other vector is not {{{undef}}}, then vector 2 must be {{{zeroinitializer}}} in canonical order. 86 106 3. If one of the vectors is a constant vector and the other vector is neither constant nor {{{undef}}}, then vector 2 must be a constant vector in canonical order. 87 4. If all of the selector values in a mask are >= n, then the vector arguments must be exchanged to be placed in canonical order. 107 4. At least one of the selector values must be < n. 108 If all of the selector values in a mask are >= n, then the vector arguments must be exchanged 109 to be place the shuffle vector instance in canonical order. 88 110 89 111 90 112 == Standard Pattern Examples == 113 114 In the following examples, the patterns are defined assuming that 115 the shufflevector arguments have been first placed in canonical form as 116 described above. 91 117 92 118 === The Rotate Pattern ===