Home | History | Annotate | Download | only in X86
      1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
      2 ; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-unknown-linux-gnu -mattr=+sse2 | FileCheck %s -check-prefixes=CHECK,SSE,SSE2
      3 ; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-unknown-linux-gnu -mattr=+sse4.1 | FileCheck %s -check-prefixes=CHECK,SSE,SSE41
      4 ; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-unknown-linux-gnu -mattr=+avx | FileCheck %s -check-prefixes=CHECK,AVX,AVX1
      5 ; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 | FileCheck %s -check-prefixes=CHECK,AVX,AVX2
      6 
      7 
      8 ; Verify the cost of vector select instructions.
      9 
     10 ; SSE41 added blend instructions with an immediate for <2 x double> and
     11 ; <4 x float>. Integers of the same size should also use those instructions.
     12 
     13 define <2 x i64> @test_2i64(<2 x i64> %a, <2 x i64> %b) {
     14 ; CHECK-LABEL: 'test_2i64'
     15 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %sel = select <2 x i1> <i1 true, i1 false>, <2 x i64> %a, <2 x i64> %b
     16 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %sel
     17 ;
     18   %sel = select <2 x i1> <i1 true, i1 false>, <2 x i64> %a, <2 x i64> %b
     19   ret <2 x i64> %sel
     20 }
     21 
     22 define <2 x double> @test_2double(<2 x double> %a, <2 x double> %b) {
     23 ; CHECK-LABEL: 'test_2double'
     24 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %sel = select <2 x i1> <i1 true, i1 false>, <2 x double> %a, <2 x double> %b
     25 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x double> %sel
     26 ;
     27   %sel = select <2 x i1> <i1 true, i1 false>, <2 x double> %a, <2 x double> %b
     28   ret <2 x double> %sel
     29 }
     30 
     31 define <4 x i32> @test_4i32(<4 x i32> %a, <4 x i32> %b) {
     32 ; CHECK-LABEL: 'test_4i32'
     33 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %sel = select <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x i32> %a, <4 x i32> %b
     34 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %sel
     35 ;
     36   %sel = select <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x i32> %a, <4 x i32> %b
     37   ret <4 x i32> %sel
     38 }
     39 
     40 define <4 x float> @test_4float(<4 x float> %a, <4 x float> %b) {
     41 ; CHECK-LABEL: 'test_4float'
     42 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %sel = select <4 x i1> <i1 true, i1 false, i1 true, i1 true>, <4 x float> %a, <4 x float> %b
     43 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x float> %sel
     44 ;
     45   %sel = select <4 x i1> <i1 true, i1 false, i1 true, i1 true>, <4 x float> %a, <4 x float> %b
     46   ret <4 x float> %sel
     47 }
     48 
     49 define <16 x i8> @test_16i8(<16 x i8> %a, <16 x i8> %b) {
     50 ; CHECK-LABEL: 'test_16i8'
     51 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %sel = select <16 x i1> <i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true>, <16 x i8> %a, <16 x i8> %b
     52 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i8> %sel
     53 ;
     54   %sel = select <16 x i1> <i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true>, <16 x i8> %a, <16 x i8> %b
     55   ret <16 x i8> %sel
     56 }
     57 
     58 ; AVX added blend instructions with an immediate for <4 x double> and
     59 ; <8 x float>. Integers of the same size should also use those instructions.
     60 define <4 x i64> @test_4i64(<4 x i64> %a, <4 x i64> %b) {
     61 ; SSE-LABEL: 'test_4i64'
     62 ; SSE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %sel = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x i64> %a, <4 x i64> %b
     63 ; SSE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %sel
     64 ;
     65 ; AVX-LABEL: 'test_4i64'
     66 ; AVX-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %sel = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x i64> %a, <4 x i64> %b
     67 ; AVX-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %sel
     68 ;
     69   %sel = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x i64> %a, <4 x i64> %b
     70   ret <4 x i64> %sel
     71 }
     72 
     73 define <4 x double> @test_4double(<4 x double> %a, <4 x double> %b) {
     74 ; SSE-LABEL: 'test_4double'
     75 ; SSE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %sel = select <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x double> %a, <4 x double> %b
     76 ; SSE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x double> %sel
     77 ;
     78 ; AVX-LABEL: 'test_4double'
     79 ; AVX-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %sel = select <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x double> %a, <4 x double> %b
     80 ; AVX-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x double> %sel
     81 ;
     82   %sel = select <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x double> %a, <4 x double> %b
     83   ret <4 x double> %sel
     84 }
     85 
     86 define <8 x i32> @test_8i32(<8 x i32> %a, <8 x i32> %b) {
     87 ; SSE-LABEL: 'test_8i32'
     88 ; SSE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %sel = select <8 x i1> <i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 false>, <8 x i32> %a, <8 x i32> %b
     89 ; SSE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %sel
     90 ;
     91 ; AVX-LABEL: 'test_8i32'
     92 ; AVX-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %sel = select <8 x i1> <i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 false>, <8 x i32> %a, <8 x i32> %b
     93 ; AVX-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %sel
     94 ;
     95   %sel = select <8 x i1> <i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 false>, <8 x i32> %a, <8 x i32> %b
     96   ret <8 x i32> %sel
     97 }
     98 
     99 define <8 x float> @test_8float(<8 x float> %a, <8 x float> %b) {
    100 ; SSE-LABEL: 'test_8float'
    101 ; SSE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %sel = select <8 x i1> <i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false>, <8 x float> %a, <8 x float> %b
    102 ; SSE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x float> %sel
    103 ;
    104 ; AVX-LABEL: 'test_8float'
    105 ; AVX-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %sel = select <8 x i1> <i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false>, <8 x float> %a, <8 x float> %b
    106 ; AVX-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x float> %sel
    107 ;
    108   %sel = select <8 x i1> <i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false>, <8 x float> %a, <8 x float> %b
    109   ret <8 x float> %sel
    110 }
    111 
    112 ; AVX2
    113 define <16 x i16> @test_16i16(<16 x i16> %a, <16 x i16> %b) {
    114 ; SSE-LABEL: 'test_16i16'
    115 ; SSE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %sel = select <16 x i1> <i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false>, <16 x i16> %a, <16 x i16> %b
    116 ; SSE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %sel
    117 ;
    118 ; AVX-LABEL: 'test_16i16'
    119 ; AVX-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %sel = select <16 x i1> <i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false>, <16 x i16> %a, <16 x i16> %b
    120 ; AVX-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %sel
    121 ;
    122   %sel = select <16 x i1> <i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false>, <16 x i16> %a, <16 x i16> %b
    123   ret <16 x i16> %sel
    124 }
    125 
    126 define <32 x i8> @test_32i8(<32 x i8> %a, <32 x i8> %b) {
    127 ; SSE-LABEL: 'test_32i8'
    128 ; SSE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %sel = select <32 x i1> <i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true>, <32 x i8> %a, <32 x i8> %b
    129 ; SSE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <32 x i8> %sel
    130 ;
    131 ; AVX-LABEL: 'test_32i8'
    132 ; AVX-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %sel = select <32 x i1> <i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true>, <32 x i8> %a, <32 x i8> %b
    133 ; AVX-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <32 x i8> %sel
    134 ;
    135   %sel = select <32 x i1> <i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true>, <32 x i8> %a, <32 x i8> %b
    136   ret <32 x i8> %sel
    137 }
    138 
    139