Home | History | Annotate | Download | only in AMDGPU
      1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
      2 
      3 ; Test that materialization constants that are the bit reversed of
      4 ; inline immediates are replaced with bfrev of the inline immediate to
      5 ; save code size.
      6 
      7 ; GCN-LABEL: {{^}}materialize_0_i32:
      8 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 0{{$}}
      9 ; GCN: buffer_store_dword [[K]]
     10 define void @materialize_0_i32(i32 addrspace(1)* %out) {
     11   store i32 0, i32 addrspace(1)* %out
     12   ret void
     13 }
     14 
     15 ; GCN-LABEL: {{^}}materialize_0_i64:
     16 ; GCN: v_mov_b32_e32 v[[LOK:[0-9]+]], 0{{$}}
     17 ; GCN: v_mov_b32_e32 v[[HIK:[0-9]+]], v[[LOK]]{{$}}
     18 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
     19 define void @materialize_0_i64(i64 addrspace(1)* %out) {
     20   store i64 0, i64 addrspace(1)* %out
     21   ret void
     22 }
     23 
     24 ; GCN-LABEL: {{^}}materialize_neg1_i32:
     25 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], -1{{$}}
     26 ; GCN: buffer_store_dword [[K]]
     27 define void @materialize_neg1_i32(i32 addrspace(1)* %out) {
     28   store i32 -1, i32 addrspace(1)* %out
     29   ret void
     30 }
     31 
     32 ; GCN-LABEL: {{^}}materialize_neg1_i64:
     33 ; GCN: v_mov_b32_e32 v[[LOK:[0-9]+]], -1{{$}}
     34 ; GCN: v_mov_b32_e32 v[[HIK:[0-9]+]], v[[LOK]]{{$}}
     35 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
     36 define void @materialize_neg1_i64(i64 addrspace(1)* %out) {
     37   store i64 -1, i64 addrspace(1)* %out
     38   ret void
     39 }
     40 
     41 ; GCN-LABEL: {{^}}materialize_signbit_i32:
     42 ; GCN: v_bfrev_b32_e32 [[K:v[0-9]+]], 1{{$}}
     43 ; GCN: buffer_store_dword [[K]]
     44 define void @materialize_signbit_i32(i32 addrspace(1)* %out) {
     45   store i32 -2147483648, i32 addrspace(1)* %out
     46   ret void
     47 }
     48 
     49 ; GCN-LABEL: {{^}}materialize_signbit_i64:
     50 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], 0{{$}}
     51 ; GCN-DAG: v_bfrev_b32_e32 v[[HIK:[0-9]+]], 1{{$}}
     52 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
     53 define void @materialize_signbit_i64(i64 addrspace(1)* %out) {
     54   store i64  -9223372036854775808, i64 addrspace(1)* %out
     55   ret void
     56 }
     57 
     58 ; GCN-LABEL: {{^}}materialize_rev_neg16_i32:
     59 ; GCN: v_bfrev_b32_e32 [[K:v[0-9]+]], -16{{$}}
     60 ; GCN: buffer_store_dword [[K]]
     61 define void @materialize_rev_neg16_i32(i32 addrspace(1)* %out) {
     62   store i32 268435455, i32 addrspace(1)* %out
     63   ret void
     64 }
     65 
     66 ; GCN-LABEL: {{^}}materialize_rev_neg16_i64:
     67 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], -1{{$}}
     68 ; GCN-DAG: v_bfrev_b32_e32 v[[HIK:[0-9]+]], -16{{$}}
     69 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
     70 define void @materialize_rev_neg16_i64(i64 addrspace(1)* %out) {
     71   store i64  1152921504606846975, i64 addrspace(1)* %out
     72   ret void
     73 }
     74 
     75 ; GCN-LABEL: {{^}}materialize_rev_neg17_i32:
     76 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 0xf7ffffff{{$}}
     77 ; GCN: buffer_store_dword [[K]]
     78 define void @materialize_rev_neg17_i32(i32 addrspace(1)* %out) {
     79   store i32 -134217729, i32 addrspace(1)* %out
     80   ret void
     81 }
     82 
     83 ; GCN-LABEL: {{^}}materialize_rev_neg17_i64:
     84 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], -1{{$}}
     85 ; GCN-DAG: v_mov_b32_e32 v[[HIK:[0-9]+]], 0xf7ffffff{{$}}
     86 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
     87 define void @materialize_rev_neg17_i64(i64 addrspace(1)* %out) {
     88   store i64 -576460752303423489, i64 addrspace(1)* %out
     89   ret void
     90 }
     91 
     92 ; GCN-LABEL: {{^}}materialize_rev_64_i32:
     93 ; GCN: v_bfrev_b32_e32 [[K:v[0-9]+]], 64{{$}}
     94 ; GCN: buffer_store_dword [[K]]
     95 define void @materialize_rev_64_i32(i32 addrspace(1)* %out) {
     96   store i32 33554432, i32 addrspace(1)* %out
     97   ret void
     98 }
     99 
    100 ; GCN-LABEL: {{^}}materialize_rev_64_i64:
    101 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], 0{{$}}
    102 ; GCN-DAG: v_bfrev_b32_e32 v[[HIK:[0-9]+]], 64{{$}}
    103 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
    104 define void @materialize_rev_64_i64(i64 addrspace(1)* %out) {
    105   store i64 144115188075855872, i64 addrspace(1)* %out
    106   ret void
    107 }
    108 
    109 ; GCN-LABEL: {{^}}materialize_rev_65_i32:
    110 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 0x82000000{{$}}
    111 ; GCN: buffer_store_dword [[K]]
    112 define void @materialize_rev_65_i32(i32 addrspace(1)* %out) {
    113   store i32 -2113929216, i32 addrspace(1)* %out
    114   ret void
    115 }
    116 
    117 ; GCN-LABEL: {{^}}materialize_rev_65_i64:
    118 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], 0{{$}}
    119 ; GCN-DAG: v_mov_b32_e32 v[[HIK:[0-9]+]], 0x82000000{{$}}
    120 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
    121 define void @materialize_rev_65_i64(i64 addrspace(1)* %out) {
    122   store i64 -9079256848778919936, i64 addrspace(1)* %out
    123   ret void
    124 }
    125 
    126 ; GCN-LABEL: {{^}}materialize_rev_3_i32:
    127 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], -2.0{{$}}
    128 ; GCN: buffer_store_dword [[K]]
    129 define void @materialize_rev_3_i32(i32 addrspace(1)* %out) {
    130   store i32 -1073741824, i32 addrspace(1)* %out
    131   ret void
    132 }
    133 
    134 ; GCN-LABEL: {{^}}materialize_rev_3_i64:
    135 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], 0{{$}}
    136 ; GCN-DAG: v_mov_b32_e32 v[[HIK:[0-9]+]], -2.0{{$}}
    137 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
    138 define void @materialize_rev_3_i64(i64 addrspace(1)* %out) {
    139   store i64 -4611686018427387904, i64 addrspace(1)* %out
    140   ret void
    141 }
    142 
    143 ; GCN-LABEL: {{^}}materialize_rev_1.0_i32:
    144 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 0x1fc{{$}}
    145 ; GCN: buffer_store_dword [[K]]
    146 define void @materialize_rev_1.0_i32(i32 addrspace(1)* %out) {
    147   store i32 508, i32 addrspace(1)* %out
    148   ret void
    149 }
    150 
    151 ; GCN-LABEL: {{^}}materialize_rev_1.0_i64:
    152 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], 0x1fc{{$}}
    153 ; GCN-DAG: v_mov_b32_e32 v[[HIK:[0-9]+]], 0{{$}}
    154 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
    155 define void @materialize_rev_1.0_i64(i64 addrspace(1)* %out) {
    156   store i64 508, i64 addrspace(1)* %out
    157   ret void
    158 }
    159