Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=CHECK-SSE2
      2 
      3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
      4 target triple = "x86_64-unknown-unknown"
      5 
      6 define <2 x i64> @shuffle_v2i64_00(<2 x i64> %a, <2 x i64> %b) {
      7 ; CHECK-SSE2-LABEL: @shuffle_v2i64_00
      8 ; CHECK-SSE2:         pshufd {{.*}} # xmm0 = xmm0[0,1,0,1]
      9 ; CHECK-SSE2-NEXT:    retq
     10   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 0, i32 0>
     11   ret <2 x i64> %shuffle
     12 }
     13 define <2 x i64> @shuffle_v2i64_10(<2 x i64> %a, <2 x i64> %b) {
     14 ; CHECK-SSE2-LABEL: @shuffle_v2i64_10
     15 ; CHECK-SSE2:         pshufd {{.*}} # xmm0 = xmm0[2,3,0,1]
     16 ; CHECK-SSE2-NEXT:    retq
     17   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 0>
     18   ret <2 x i64> %shuffle
     19 }
     20 define <2 x i64> @shuffle_v2i64_11(<2 x i64> %a, <2 x i64> %b) {
     21 ; CHECK-SSE2-LABEL: @shuffle_v2i64_11
     22 ; CHECK-SSE2:         pshufd {{.*}} # xmm0 = xmm0[2,3,2,3]
     23 ; CHECK-SSE2-NEXT:    retq
     24   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 1>
     25   ret <2 x i64> %shuffle
     26 }
     27 define <2 x i64> @shuffle_v2i64_22(<2 x i64> %a, <2 x i64> %b) {
     28 ; CHECK-SSE2-LABEL: @shuffle_v2i64_22
     29 ; CHECK-SSE2:         pshufd {{.*}} # xmm0 = xmm1[0,1,0,1]
     30 ; CHECK-SSE2-NEXT:    retq
     31   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 2, i32 2>
     32   ret <2 x i64> %shuffle
     33 }
     34 define <2 x i64> @shuffle_v2i64_32(<2 x i64> %a, <2 x i64> %b) {
     35 ; CHECK-SSE2-LABEL: @shuffle_v2i64_32
     36 ; CHECK-SSE2:         pshufd {{.*}} # xmm0 = xmm1[2,3,0,1]
     37 ; CHECK-SSE2-NEXT:    retq
     38   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 2>
     39   ret <2 x i64> %shuffle
     40 }
     41 define <2 x i64> @shuffle_v2i64_33(<2 x i64> %a, <2 x i64> %b) {
     42 ; CHECK-SSE2-LABEL: @shuffle_v2i64_33
     43 ; CHECK-SSE2:         pshufd {{.*}} # xmm0 = xmm1[2,3,2,3]
     44 ; CHECK-SSE2-NEXT:    retq
     45   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 3>
     46   ret <2 x i64> %shuffle
     47 }
     48 
     49 define <2 x double> @shuffle_v2f64_00(<2 x double> %a, <2 x double> %b) {
     50 ; CHECK-SSE2-LABEL: @shuffle_v2f64_00
     51 ; CHECK-SSE2:         shufpd {{.*}} # xmm0 = xmm0[0,0]
     52 ; CHECK-SSE2-NEXT:    retq
     53   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 0, i32 0>
     54   ret <2 x double> %shuffle
     55 }
     56 define <2 x double> @shuffle_v2f64_10(<2 x double> %a, <2 x double> %b) {
     57 ; CHECK-SSE2-LABEL: @shuffle_v2f64_10
     58 ; CHECK-SSE2:         shufpd {{.*}} # xmm0 = xmm0[1,0]
     59 ; CHECK-SSE2-NEXT:    retq
     60   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 1, i32 0>
     61   ret <2 x double> %shuffle
     62 }
     63 define <2 x double> @shuffle_v2f64_11(<2 x double> %a, <2 x double> %b) {
     64 ; CHECK-SSE2-LABEL: @shuffle_v2f64_11
     65 ; CHECK-SSE2:         shufpd {{.*}} # xmm0 = xmm0[1,1]
     66 ; CHECK-SSE2-NEXT:    retq
     67   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 1, i32 1>
     68   ret <2 x double> %shuffle
     69 }
     70 define <2 x double> @shuffle_v2f64_22(<2 x double> %a, <2 x double> %b) {
     71 ; FIXME: Should these use movapd + shufpd to remove a domain change at the cost
     72 ;        of a mov?
     73 ;
     74 ; CHECK-SSE2-LABEL: @shuffle_v2f64_22
     75 ; CHECK-SSE2:         pshufd {{.*}} # xmm0 = xmm1[0,1,0,1]
     76 ; CHECK-SSE2-NEXT:    retq
     77   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 2, i32 2>
     78   ret <2 x double> %shuffle
     79 }
     80 define <2 x double> @shuffle_v2f64_32(<2 x double> %a, <2 x double> %b) {
     81 ; CHECK-SSE2-LABEL: @shuffle_v2f64_32
     82 ; CHECK-SSE2:         pshufd {{.*}} # xmm0 = xmm1[2,3,0,1]
     83 ; CHECK-SSE2-NEXT:    retq
     84   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 3, i32 2>
     85   ret <2 x double> %shuffle
     86 }
     87 define <2 x double> @shuffle_v2f64_33(<2 x double> %a, <2 x double> %b) {
     88 ; CHECK-SSE2-LABEL: @shuffle_v2f64_33
     89 ; CHECK-SSE2:         pshufd {{.*}} # xmm0 = xmm1[2,3,2,3]
     90 ; CHECK-SSE2-NEXT:    retq
     91   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 3, i32 3>
     92   ret <2 x double> %shuffle
     93 }
     94 
     95 
     96 define <2 x i64> @shuffle_v2i64_02(<2 x i64> %a, <2 x i64> %b) {
     97 ; CHECK-SSE2-LABEL: @shuffle_v2i64_02
     98 ; CHECK-SSE2:         shufpd {{.*}} # xmm0 = xmm0[0],xmm1[0]
     99 ; CHECK-SSE2-NEXT:    retq
    100   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 0, i32 2>
    101   ret <2 x i64> %shuffle
    102 }
    103 define <2 x i64> @shuffle_v2i64_02_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
    104 ; CHECK-SSE2-LABEL: @shuffle_v2i64_02_copy
    105 ; CHECK-SSE2:         shufpd {{.*}} # xmm1 = xmm1[0],xmm2[0]
    106 ; CHECK-SSE2-NEXT:    movapd %xmm1, %xmm0
    107 ; CHECK-SSE2-NEXT:    retq
    108   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 0, i32 2>
    109   ret <2 x i64> %shuffle
    110 }
    111 define <2 x i64> @shuffle_v2i64_03(<2 x i64> %a, <2 x i64> %b) {
    112 ; CHECK-SSE2-LABEL: @shuffle_v2i64_03
    113 ; CHECK-SSE2:         shufpd {{.*}} # xmm0 = xmm0[0],xmm1[1]
    114 ; CHECK-SSE2-NEXT:    retq
    115   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 0, i32 3>
    116   ret <2 x i64> %shuffle
    117 }
    118 define <2 x i64> @shuffle_v2i64_03_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
    119 ; CHECK-SSE2-LABEL: @shuffle_v2i64_03_copy
    120 ; CHECK-SSE2:         shufpd {{.*}} # xmm1 = xmm1[0],xmm2[1]
    121 ; CHECK-SSE2-NEXT:    movapd %xmm1, %xmm0
    122 ; CHECK-SSE2-NEXT:    retq
    123   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 0, i32 3>
    124   ret <2 x i64> %shuffle
    125 }
    126 define <2 x i64> @shuffle_v2i64_12(<2 x i64> %a, <2 x i64> %b) {
    127 ; CHECK-SSE2-LABEL: @shuffle_v2i64_12
    128 ; CHECK-SSE2:         shufpd {{.*}} # xmm0 = xmm0[1],xmm1[0]
    129 ; CHECK-SSE2-NEXT:    retq
    130   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 2>
    131   ret <2 x i64> %shuffle
    132 }
    133 define <2 x i64> @shuffle_v2i64_12_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
    134 ; CHECK-SSE2-LABEL: @shuffle_v2i64_12_copy
    135 ; CHECK-SSE2:         shufpd {{.*}} # xmm1 = xmm1[1],xmm2[0]
    136 ; CHECK-SSE2-NEXT:    movapd %xmm1, %xmm0
    137 ; CHECK-SSE2-NEXT:    retq
    138   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 2>
    139   ret <2 x i64> %shuffle
    140 }
    141 define <2 x i64> @shuffle_v2i64_13(<2 x i64> %a, <2 x i64> %b) {
    142 ; CHECK-SSE2-LABEL: @shuffle_v2i64_13
    143 ; CHECK-SSE2:         shufpd {{.*}} # xmm0 = xmm0[1],xmm1[1]
    144 ; CHECK-SSE2-NEXT:    retq
    145   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 3>
    146   ret <2 x i64> %shuffle
    147 }
    148 define <2 x i64> @shuffle_v2i64_13_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
    149 ; CHECK-SSE2-LABEL: @shuffle_v2i64_13_copy
    150 ; CHECK-SSE2:         shufpd {{.*}} # xmm1 = xmm1[1],xmm2[1]
    151 ; CHECK-SSE2-NEXT:    movapd %xmm1, %xmm0
    152 ; CHECK-SSE2-NEXT:    retq
    153   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 3>
    154   ret <2 x i64> %shuffle
    155 }
    156 define <2 x i64> @shuffle_v2i64_20(<2 x i64> %a, <2 x i64> %b) {
    157 ; CHECK-SSE2-LABEL: @shuffle_v2i64_20
    158 ; CHECK-SSE2:         shufpd {{.*}} # xmm1 = xmm1[0],xmm0[0]
    159 ; CHECK-SSE2-NEXT:    movapd %xmm1, %xmm0
    160 ; CHECK-SSE2-NEXT:    retq
    161   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 2, i32 0>
    162   ret <2 x i64> %shuffle
    163 }
    164 define <2 x i64> @shuffle_v2i64_20_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
    165 ; CHECK-SSE2-LABEL: @shuffle_v2i64_20_copy
    166 ; CHECK-SSE2:         shufpd {{.*}} # xmm2 = xmm2[0],xmm1[0]
    167 ; CHECK-SSE2-NEXT:    movapd %xmm2, %xmm0
    168 ; CHECK-SSE2-NEXT:    retq
    169   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 2, i32 0>
    170   ret <2 x i64> %shuffle
    171 }
    172 define <2 x i64> @shuffle_v2i64_21(<2 x i64> %a, <2 x i64> %b) {
    173 ; CHECK-SSE2-LABEL: @shuffle_v2i64_21
    174 ; CHECK-SSE2:         shufpd {{.*}} # xmm1 = xmm1[0],xmm0[1]
    175 ; CHECK-SSE2-NEXT:    movapd %xmm1, %xmm0
    176 ; CHECK-SSE2-NEXT:    retq
    177   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 2, i32 1>
    178   ret <2 x i64> %shuffle
    179 }
    180 define <2 x i64> @shuffle_v2i64_21_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
    181 ; CHECK-SSE2-LABEL: @shuffle_v2i64_21_copy
    182 ; CHECK-SSE2:         shufpd {{.*}} # xmm2 = xmm2[0],xmm1[1]
    183 ; CHECK-SSE2-NEXT:    movapd %xmm2, %xmm0
    184 ; CHECK-SSE2-NEXT:    retq
    185   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 2, i32 1>
    186   ret <2 x i64> %shuffle
    187 }
    188 define <2 x i64> @shuffle_v2i64_30(<2 x i64> %a, <2 x i64> %b) {
    189 ; CHECK-SSE2-LABEL: @shuffle_v2i64_30
    190 ; CHECK-SSE2:         shufpd {{.*}} # xmm1 = xmm1[1],xmm0[0]
    191 ; CHECK-SSE2-NEXT:    movapd %xmm1, %xmm0
    192 ; CHECK-SSE2-NEXT:    retq
    193   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 0>
    194   ret <2 x i64> %shuffle
    195 }
    196 define <2 x i64> @shuffle_v2i64_30_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
    197 ; CHECK-SSE2-LABEL: @shuffle_v2i64_30_copy
    198 ; CHECK-SSE2:         shufpd {{.*}} # xmm2 = xmm2[1],xmm1[0]
    199 ; CHECK-SSE2-NEXT:    movapd %xmm2, %xmm0
    200 ; CHECK-SSE2-NEXT:    retq
    201   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 0>
    202   ret <2 x i64> %shuffle
    203 }
    204 define <2 x i64> @shuffle_v2i64_31(<2 x i64> %a, <2 x i64> %b) {
    205 ; CHECK-SSE2-LABEL: @shuffle_v2i64_31
    206 ; CHECK-SSE2:         shufpd {{.*}} # xmm1 = xmm1[1],xmm0[1]
    207 ; CHECK-SSE2-NEXT:    movapd %xmm1, %xmm0
    208 ; CHECK-SSE2-NEXT:    retq
    209   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 1>
    210   ret <2 x i64> %shuffle
    211 }
    212 define <2 x i64> @shuffle_v2i64_31_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
    213 ; CHECK-SSE2-LABEL: @shuffle_v2i64_31_copy
    214 ; CHECK-SSE2:         shufpd {{.*}} # xmm2 = xmm2[1],xmm1[1]
    215 ; CHECK-SSE2-NEXT:    movapd %xmm2, %xmm0
    216 ; CHECK-SSE2-NEXT:    retq
    217   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 1>
    218   ret <2 x i64> %shuffle
    219 }
    220