| Matt Arsenault | ce84130 | 2016-12-22 03:05:37 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s | 
|  | 2 |  | 
|  | 3 | declare half @llvm.canonicalize.f16(half) #0 | 
|  | 4 |  | 
|  | 5 | ; GCN-LABEL: {{^}}v_test_canonicalize_var_f16: | 
|  | 6 | ; GCN: v_mul_f16_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}} | 
|  | 7 | ; GCN: buffer_store_short [[REG]] | 
|  | 8 | define void @v_test_canonicalize_var_f16(half addrspace(1)* %out) #1 { | 
|  | 9 | %val = load half, half addrspace(1)* %out | 
|  | 10 | %canonicalized = call half @llvm.canonicalize.f16(half %val) | 
|  | 11 | store half %canonicalized, half addrspace(1)* %out | 
|  | 12 | ret void | 
|  | 13 | } | 
|  | 14 |  | 
|  | 15 | ; GCN-LABEL: {{^}}s_test_canonicalize_var_f16: | 
|  | 16 | ; GCN: v_mul_f16_e64 [[REG:v[0-9]+]], 1.0, {{s[0-9]+}} | 
|  | 17 | ; GCN: buffer_store_short [[REG]] | 
|  | 18 | define void @s_test_canonicalize_var_f16(half addrspace(1)* %out, i16 zeroext %val.arg) #1 { | 
|  | 19 | %val = bitcast i16 %val.arg to half | 
|  | 20 | %canonicalized = call half @llvm.canonicalize.f16(half %val) | 
|  | 21 | store half %canonicalized, half addrspace(1)* %out | 
|  | 22 | ret void | 
|  | 23 | } | 
|  | 24 |  | 
|  | 25 | ; GCN-LABEL: {{^}}test_fold_canonicalize_p0_f16: | 
|  | 26 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0{{$}} | 
|  | 27 | ; GCN: buffer_store_short [[REG]] | 
|  | 28 | define void @test_fold_canonicalize_p0_f16(half addrspace(1)* %out) #1 { | 
|  | 29 | %canonicalized = call half @llvm.canonicalize.f16(half 0.0) | 
|  | 30 | store half %canonicalized, half addrspace(1)* %out | 
|  | 31 | ret void | 
|  | 32 | } | 
|  | 33 |  | 
|  | 34 | ; GCN-LABEL: {{^}}test_fold_canonicalize_n0_f16: | 
|  | 35 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0xffff8000{{$}} | 
|  | 36 | ; GCN: buffer_store_short [[REG]] | 
|  | 37 | define void @test_fold_canonicalize_n0_f16(half addrspace(1)* %out) #1 { | 
|  | 38 | %canonicalized = call half @llvm.canonicalize.f16(half -0.0) | 
|  | 39 | store half %canonicalized, half addrspace(1)* %out | 
|  | 40 | ret void | 
|  | 41 | } | 
|  | 42 |  | 
|  | 43 | ; GCN-LABEL: {{^}}test_fold_canonicalize_p1_f16: | 
|  | 44 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x3c00{{$}} | 
|  | 45 | ; GCN: buffer_store_short [[REG]] | 
|  | 46 | define void @test_fold_canonicalize_p1_f16(half addrspace(1)* %out) #1 { | 
|  | 47 | %canonicalized = call half @llvm.canonicalize.f16(half 1.0) | 
|  | 48 | store half %canonicalized, half addrspace(1)* %out | 
|  | 49 | ret void | 
|  | 50 | } | 
|  | 51 |  | 
|  | 52 | ; GCN-LABEL: {{^}}test_fold_canonicalize_n1_f16: | 
|  | 53 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0xffffbc00{{$}} | 
|  | 54 | ; GCN: buffer_store_short [[REG]] | 
|  | 55 | define void @test_fold_canonicalize_n1_f16(half addrspace(1)* %out) #1 { | 
|  | 56 | %canonicalized = call half @llvm.canonicalize.f16(half -1.0) | 
|  | 57 | store half %canonicalized, half addrspace(1)* %out | 
|  | 58 | ret void | 
|  | 59 | } | 
|  | 60 |  | 
|  | 61 | ; GCN-LABEL: {{^}}test_fold_canonicalize_literal_f16: | 
|  | 62 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x4c00{{$}} | 
|  | 63 | ; GCN: buffer_store_short [[REG]] | 
|  | 64 | define void @test_fold_canonicalize_literal_f16(half addrspace(1)* %out) #1 { | 
|  | 65 | %canonicalized = call half @llvm.canonicalize.f16(half 16.0) | 
|  | 66 | store half %canonicalized, half addrspace(1)* %out | 
|  | 67 | ret void | 
|  | 68 | } | 
|  | 69 |  | 
|  | 70 | ; GCN-LABEL: {{^}}test_no_denormals_fold_canonicalize_denormal0_f16: | 
|  | 71 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0{{$}} | 
|  | 72 | ; GCN: buffer_store_short [[REG]] | 
|  | 73 | define void @test_no_denormals_fold_canonicalize_denormal0_f16(half addrspace(1)* %out) #1 { | 
|  | 74 | %canonicalized = call half @llvm.canonicalize.f16(half 0xH03FF) | 
|  | 75 | store half %canonicalized, half addrspace(1)* %out | 
|  | 76 | ret void | 
|  | 77 | } | 
|  | 78 |  | 
|  | 79 | ; GCN-LABEL: {{^}}test_denormals_fold_canonicalize_denormal0_f16: | 
|  | 80 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x3ff{{$}} | 
|  | 81 | ; GCN: buffer_store_short [[REG]] | 
|  | 82 | define void @test_denormals_fold_canonicalize_denormal0_f16(half addrspace(1)* %out) #3 { | 
|  | 83 | %canonicalized = call half @llvm.canonicalize.f16(half 0xH03FF) | 
|  | 84 | store half %canonicalized, half addrspace(1)* %out | 
|  | 85 | ret void | 
|  | 86 | } | 
|  | 87 |  | 
|  | 88 | ; GCN-LABEL: {{^}}test_no_denormals_fold_canonicalize_denormal1_f16: | 
|  | 89 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0{{$}} | 
|  | 90 | ; GCN: buffer_store_short [[REG]] | 
|  | 91 | define void @test_no_denormals_fold_canonicalize_denormal1_f16(half addrspace(1)* %out) #1 { | 
|  | 92 | %canonicalized = call half @llvm.canonicalize.f16(half 0xH83FF) | 
|  | 93 | store half %canonicalized, half addrspace(1)* %out | 
|  | 94 | ret void | 
|  | 95 | } | 
|  | 96 |  | 
|  | 97 | ; GCN-LABEL: {{^}}test_denormals_fold_canonicalize_denormal1_f16: | 
|  | 98 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0xffff83ff{{$}} | 
|  | 99 | ; GCN: buffer_store_short [[REG]] | 
|  | 100 | define void @test_denormals_fold_canonicalize_denormal1_f16(half addrspace(1)* %out) #3 { | 
|  | 101 | %canonicalized = call half @llvm.canonicalize.f16(half 0xH83FF) | 
|  | 102 | store half %canonicalized, half addrspace(1)* %out | 
|  | 103 | ret void | 
|  | 104 | } | 
|  | 105 |  | 
|  | 106 | ; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_f16: | 
|  | 107 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7c00{{$}} | 
|  | 108 | ; GCN: buffer_store_short [[REG]] | 
|  | 109 | define void @test_fold_canonicalize_qnan_f16(half addrspace(1)* %out) #1 { | 
|  | 110 | %canonicalized = call half @llvm.canonicalize.f16(half 0xH7C00) | 
|  | 111 | store half %canonicalized, half addrspace(1)* %out | 
|  | 112 | ret void | 
|  | 113 | } | 
|  | 114 |  | 
|  | 115 | ; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_value_neg1_f16: | 
|  | 116 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7e00{{$}} | 
|  | 117 | ; GCN: buffer_store_short [[REG]] | 
|  | 118 | define void @test_fold_canonicalize_qnan_value_neg1_f16(half addrspace(1)* %out) #1 { | 
|  | 119 | %canonicalized = call half @llvm.canonicalize.f16(half bitcast (i16 -1 to half)) | 
|  | 120 | store half %canonicalized, half addrspace(1)* %out | 
|  | 121 | ret void | 
|  | 122 | } | 
|  | 123 |  | 
|  | 124 | ; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_value_neg2_f16: | 
|  | 125 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7e00{{$}} | 
|  | 126 | ; GCN: buffer_store_short [[REG]] | 
|  | 127 | define void @test_fold_canonicalize_qnan_value_neg2_f16(half addrspace(1)* %out) #1 { | 
|  | 128 | %canonicalized = call half @llvm.canonicalize.f16(half bitcast (i16 -2 to half)) | 
|  | 129 | store half %canonicalized, half addrspace(1)* %out | 
|  | 130 | ret void | 
|  | 131 | } | 
|  | 132 |  | 
|  | 133 | ; GCN-LABEL: {{^}}test_fold_canonicalize_snan0_value_f16: | 
|  | 134 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7e00{{$}} | 
|  | 135 | ; GCN: buffer_store_short [[REG]] | 
|  | 136 | define void @test_fold_canonicalize_snan0_value_f16(half addrspace(1)* %out) #1 { | 
|  | 137 | %canonicalized = call half @llvm.canonicalize.f16(half 0xH7C01) | 
|  | 138 | store half %canonicalized, half addrspace(1)* %out | 
|  | 139 | ret void | 
|  | 140 | } | 
|  | 141 |  | 
|  | 142 | ; GCN-LABEL: {{^}}test_fold_canonicalize_snan1_value_f16: | 
|  | 143 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7e00{{$}} | 
|  | 144 | ; GCN: buffer_store_short [[REG]] | 
|  | 145 | define void @test_fold_canonicalize_snan1_value_f16(half addrspace(1)* %out) #1 { | 
|  | 146 | %canonicalized = call half @llvm.canonicalize.f16(half 0xH7DFF) | 
|  | 147 | store half %canonicalized, half addrspace(1)* %out | 
|  | 148 | ret void | 
|  | 149 | } | 
|  | 150 |  | 
|  | 151 | ; GCN-LABEL: {{^}}test_fold_canonicalize_snan2_value_f16: | 
|  | 152 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7e00{{$}} | 
|  | 153 | ; GCN: buffer_store_short [[REG]] | 
|  | 154 | define void @test_fold_canonicalize_snan2_value_f16(half addrspace(1)* %out) #1 { | 
|  | 155 | %canonicalized = call half @llvm.canonicalize.f16(half 0xHFDFF) | 
|  | 156 | store half %canonicalized, half addrspace(1)* %out | 
|  | 157 | ret void | 
|  | 158 | } | 
|  | 159 |  | 
|  | 160 | ; GCN-LABEL: {{^}}test_fold_canonicalize_snan3_value_f16: | 
|  | 161 | ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7e00{{$}} | 
|  | 162 | ; GCN: buffer_store_short [[REG]] | 
|  | 163 | define void @test_fold_canonicalize_snan3_value_f16(half addrspace(1)* %out) #1 { | 
|  | 164 | %canonicalized = call half @llvm.canonicalize.f16(half 0xHFC01) | 
|  | 165 | store half %canonicalized, half addrspace(1)* %out | 
|  | 166 | ret void | 
|  | 167 | } | 
|  | 168 |  | 
|  | 169 | attributes #0 = { nounwind readnone } | 
|  | 170 | attributes #1 = { nounwind } | 
|  | 171 | attributes #2 = { nounwind "target-features"="-fp16-denormals,-fp16-denormals" } | 
|  | 172 | attributes #3 = { nounwind "target-features"="+fp16-denormals,+fp64-denormals" } |