| Matt Arsenault | f639c32 | 2016-01-28 20:53:42 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s | 
| Matt Arsenault | 7aad8fd | 2017-01-24 22:02:15 +0000 | [diff] [blame] | 2 | ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s | 
| Matt Arsenault | f639c32 | 2016-01-28 20:53:42 +0000 | [diff] [blame] | 3 |  | 
|  | 4 | declare i32 @llvm.r600.read.tidig.x() #0 | 
|  | 5 |  | 
|  | 6 | ; GCN-LABEL: {{^}}v_test_umed3_r_i_i_i32: | 
|  | 7 | ; GCN: v_med3_u32 v{{[0-9]+}}, v{{[0-9]+}}, 12, 17 | 
|  | 8 | define void @v_test_umed3_r_i_i_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) #1 { | 
|  | 9 | %tid = call i32 @llvm.r600.read.tidig.x() | 
|  | 10 | %gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid | 
|  | 11 | %outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid | 
|  | 12 | %a = load i32, i32 addrspace(1)* %gep0 | 
|  | 13 |  | 
|  | 14 | %icmp0 = icmp ugt i32 %a, 12 | 
|  | 15 | %i0 = select i1 %icmp0, i32 %a, i32 12 | 
|  | 16 |  | 
|  | 17 | %icmp1 = icmp ult i32 %i0, 17 | 
|  | 18 | %i1 = select i1 %icmp1, i32 %i0, i32 17 | 
|  | 19 |  | 
|  | 20 | store i32 %i1, i32 addrspace(1)* %outgep | 
|  | 21 | ret void | 
|  | 22 | } | 
|  | 23 |  | 
|  | 24 | ; GCN-LABEL: {{^}}v_test_umed3_multi_use_r_i_i_i32: | 
|  | 25 | ; GCN: v_max_u32 | 
|  | 26 | ; GCN: v_min_u32 | 
|  | 27 | define void @v_test_umed3_multi_use_r_i_i_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) #1 { | 
|  | 28 | %tid = call i32 @llvm.r600.read.tidig.x() | 
|  | 29 | %gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid | 
|  | 30 | %outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid | 
|  | 31 | %a = load i32, i32 addrspace(1)* %gep0 | 
|  | 32 |  | 
|  | 33 | %icmp0 = icmp ugt i32 %a, 12 | 
|  | 34 | %i0 = select i1 %icmp0, i32 %a, i32 12 | 
|  | 35 |  | 
|  | 36 | %icmp1 = icmp ult i32 %i0, 17 | 
|  | 37 | %i1 = select i1 %icmp1, i32 %i0, i32 17 | 
|  | 38 |  | 
|  | 39 | store volatile i32 %i0, i32 addrspace(1)* %outgep | 
|  | 40 | store volatile i32 %i1, i32 addrspace(1)* %outgep | 
|  | 41 | ret void | 
|  | 42 | } | 
|  | 43 |  | 
|  | 44 | ; GCN-LABEL: {{^}}v_test_umed3_r_i_i_constant_order_i32: | 
|  | 45 | ; GCN: v_max_u32_e32 v{{[0-9]+}}, 17, v{{[0-9]+}} | 
|  | 46 | ; GCN: v_min_u32_e32 v{{[0-9]+}}, 12, v{{[0-9]+}} | 
|  | 47 | define void @v_test_umed3_r_i_i_constant_order_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) #1 { | 
|  | 48 | %tid = call i32 @llvm.r600.read.tidig.x() | 
|  | 49 | %gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid | 
|  | 50 | %outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid | 
|  | 51 | %a = load i32, i32 addrspace(1)* %gep0 | 
|  | 52 |  | 
|  | 53 | %icmp0 = icmp ugt i32 %a, 17 | 
|  | 54 | %i0 = select i1 %icmp0, i32 %a, i32 17 | 
|  | 55 |  | 
|  | 56 | %icmp1 = icmp ult i32 %i0, 12 | 
|  | 57 | %i1 = select i1 %icmp1, i32 %i0, i32 12 | 
|  | 58 |  | 
|  | 59 | store i32 %i1, i32 addrspace(1)* %outgep | 
|  | 60 | ret void | 
|  | 61 | } | 
|  | 62 |  | 
|  | 63 | ; GCN-LABEL: {{^}}v_test_umed3_r_i_i_sign_mismatch_i32: | 
|  | 64 | ; GCN: v_max_i32_e32 v{{[0-9]+}}, 12, v{{[0-9]+}} | 
|  | 65 | ; GCN: v_min_u32_e32 v{{[0-9]+}}, 17, v{{[0-9]+}} | 
|  | 66 | define void @v_test_umed3_r_i_i_sign_mismatch_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) #1 { | 
|  | 67 | %tid = call i32 @llvm.r600.read.tidig.x() | 
|  | 68 | %gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid | 
|  | 69 | %outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid | 
|  | 70 | %a = load i32, i32 addrspace(1)* %gep0 | 
|  | 71 |  | 
|  | 72 | %icmp0 = icmp sgt i32 %a, 12 | 
|  | 73 | %i0 = select i1 %icmp0, i32 %a, i32 12 | 
|  | 74 |  | 
|  | 75 | %icmp1 = icmp ult i32 %i0, 17 | 
|  | 76 | %i1 = select i1 %icmp1, i32 %i0, i32 17 | 
|  | 77 |  | 
|  | 78 | store i32 %i1, i32 addrspace(1)* %outgep | 
|  | 79 | ret void | 
|  | 80 | } | 
|  | 81 |  | 
|  | 82 | ; GCN-LABEL: {{^}}v_test_umed3_r_i_i_i64: | 
|  | 83 | ; GCN: v_cmp_lt_u64 | 
|  | 84 | ; GCN: v_cmp_gt_u64 | 
|  | 85 | define void @v_test_umed3_r_i_i_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) #1 { | 
|  | 86 | %tid = call i32 @llvm.r600.read.tidig.x() | 
|  | 87 | %gep0 = getelementptr i64, i64 addrspace(1)* %aptr, i32 %tid | 
|  | 88 | %outgep = getelementptr i64, i64 addrspace(1)* %out, i32 %tid | 
|  | 89 | %a = load i64, i64 addrspace(1)* %gep0 | 
|  | 90 |  | 
|  | 91 | %icmp0 = icmp ugt i64 %a, 12 | 
|  | 92 | %i0 = select i1 %icmp0, i64 %a, i64 12 | 
|  | 93 |  | 
|  | 94 | %icmp1 = icmp ult i64 %i0, 17 | 
|  | 95 | %i1 = select i1 %icmp1, i64 %i0, i64 17 | 
|  | 96 |  | 
|  | 97 | store i64 %i1, i64 addrspace(1)* %outgep | 
|  | 98 | ret void | 
|  | 99 | } | 
|  | 100 |  | 
|  | 101 | ; GCN-LABEL: {{^}}v_test_umed3_r_i_i_i16: | 
|  | 102 | ; GCN: v_med3_u32 v{{[0-9]+}}, v{{[0-9]+}}, 12, 17 | 
|  | 103 | define void @v_test_umed3_r_i_i_i16(i16 addrspace(1)* %out, i16 addrspace(1)* %aptr) #1 { | 
|  | 104 | %tid = call i32 @llvm.r600.read.tidig.x() | 
|  | 105 | %gep0 = getelementptr i16, i16 addrspace(1)* %aptr, i32 %tid | 
|  | 106 | %outgep = getelementptr i16, i16 addrspace(1)* %out, i32 %tid | 
|  | 107 | %a = load i16, i16 addrspace(1)* %gep0 | 
|  | 108 |  | 
|  | 109 | %icmp0 = icmp ugt i16 %a, 12 | 
|  | 110 | %i0 = select i1 %icmp0, i16 %a, i16 12 | 
|  | 111 |  | 
|  | 112 | %icmp1 = icmp ult i16 %i0, 17 | 
|  | 113 | %i1 = select i1 %icmp1, i16 %i0, i16 17 | 
|  | 114 |  | 
|  | 115 | store i16 %i1, i16 addrspace(1)* %outgep | 
|  | 116 | ret void | 
|  | 117 | } | 
| Matt Arsenault | c89f291 | 2016-03-07 21:54:48 +0000 | [diff] [blame] | 118 |  | 
|  | 119 | define internal i32 @umin(i32 %x, i32 %y) #2 { | 
|  | 120 | %cmp = icmp ult i32 %x, %y | 
|  | 121 | %sel = select i1 %cmp, i32 %x, i32 %y | 
|  | 122 | ret i32 %sel | 
|  | 123 | } | 
|  | 124 |  | 
|  | 125 | define internal i32 @umax(i32 %x, i32 %y) #2 { | 
|  | 126 | %cmp = icmp ugt i32 %x, %y | 
|  | 127 | %sel = select i1 %cmp, i32 %x, i32 %y | 
|  | 128 | ret i32 %sel | 
|  | 129 | } | 
|  | 130 |  | 
|  | 131 | define internal i16 @umin16(i16 %x, i16 %y) #2 { | 
|  | 132 | %cmp = icmp ult i16 %x, %y | 
|  | 133 | %sel = select i1 %cmp, i16 %x, i16 %y | 
|  | 134 | ret i16 %sel | 
|  | 135 | } | 
|  | 136 |  | 
|  | 137 | define internal i16 @umax16(i16 %x, i16 %y) #2 { | 
|  | 138 | %cmp = icmp ugt i16 %x, %y | 
|  | 139 | %sel = select i1 %cmp, i16 %x, i16 %y | 
|  | 140 | ret i16 %sel | 
|  | 141 | } | 
|  | 142 |  | 
|  | 143 | define internal i8 @umin8(i8 %x, i8 %y) #2 { | 
|  | 144 | %cmp = icmp ult i8 %x, %y | 
|  | 145 | %sel = select i1 %cmp, i8 %x, i8 %y | 
|  | 146 | ret i8 %sel | 
|  | 147 | } | 
|  | 148 |  | 
|  | 149 | define internal i8 @umax8(i8 %x, i8 %y) #2 { | 
|  | 150 | %cmp = icmp ugt i8 %x, %y | 
|  | 151 | %sel = select i1 %cmp, i8 %x, i8 %y | 
|  | 152 | ret i8 %sel | 
|  | 153 | } | 
|  | 154 |  | 
|  | 155 | ; 16 combinations | 
|  | 156 |  | 
|  | 157 | ; 0: max(min(x, y), min(max(x, y), z)) | 
|  | 158 | ; 1: max(min(x, y), min(max(y, x), z)) | 
|  | 159 | ; 2: max(min(x, y), min(z, max(x, y))) | 
|  | 160 | ; 3: max(min(x, y), min(z, max(y, x))) | 
|  | 161 | ; 4: max(min(y, x), min(max(x, y), z)) | 
|  | 162 | ; 5: max(min(y, x), min(max(y, x), z)) | 
|  | 163 | ; 6: max(min(y, x), min(z, max(x, y))) | 
|  | 164 | ; 7: max(min(y, x), min(z, max(y, x))) | 
|  | 165 | ; | 
|  | 166 | ; + commute outermost max | 
|  | 167 |  | 
|  | 168 |  | 
|  | 169 | ; FIXME: In these cases we probably should have used scalar operations | 
|  | 170 | ; instead. | 
|  | 171 |  | 
|  | 172 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_0: | 
|  | 173 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 174 | define void @s_test_umed3_i32_pat_0(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 175 | bb: | 
|  | 176 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 177 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 178 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 179 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 180 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 181 | ret void | 
|  | 182 | } | 
|  | 183 |  | 
|  | 184 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_1: | 
|  | 185 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 186 | define void @s_test_umed3_i32_pat_1(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 187 | bb: | 
|  | 188 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 189 | %tmp1 = call i32 @umax(i32 %y, i32 %x) | 
|  | 190 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 191 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 192 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 193 | ret void | 
|  | 194 | } | 
|  | 195 |  | 
|  | 196 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_2: | 
|  | 197 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 198 | define void @s_test_umed3_i32_pat_2(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 199 | bb: | 
|  | 200 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 201 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 202 | %tmp2 = call i32 @umin(i32 %z, i32 %tmp1) | 
|  | 203 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 204 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 205 | ret void | 
|  | 206 | } | 
|  | 207 |  | 
|  | 208 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_3: | 
|  | 209 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 210 | define void @s_test_umed3_i32_pat_3(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 211 | bb: | 
|  | 212 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 213 | %tmp1 = call i32 @umax(i32 %y, i32 %x) | 
|  | 214 | %tmp2 = call i32 @umin(i32 %z, i32 %tmp1) | 
|  | 215 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 216 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 217 | ret void | 
|  | 218 | } | 
|  | 219 |  | 
|  | 220 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_4: | 
|  | 221 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 222 | define void @s_test_umed3_i32_pat_4(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 223 | bb: | 
|  | 224 | %tmp0 = call i32 @umin(i32 %y, i32 %x) | 
|  | 225 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 226 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 227 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 228 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 229 | ret void | 
|  | 230 | } | 
|  | 231 |  | 
|  | 232 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_5: | 
|  | 233 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 234 | define void @s_test_umed3_i32_pat_5(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 235 | bb: | 
|  | 236 | %tmp0 = call i32 @umin(i32 %y, i32 %x) | 
|  | 237 | %tmp1 = call i32 @umax(i32 %y, i32 %x) | 
|  | 238 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 239 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 240 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 241 | ret void | 
|  | 242 | } | 
|  | 243 |  | 
|  | 244 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_6: | 
|  | 245 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 246 | define void @s_test_umed3_i32_pat_6(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 247 | bb: | 
|  | 248 | %tmp0 = call i32 @umin(i32 %y, i32 %x) | 
|  | 249 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 250 | %tmp2 = call i32 @umin(i32 %z, i32 %tmp1) | 
|  | 251 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 252 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 253 | ret void | 
|  | 254 | } | 
|  | 255 |  | 
|  | 256 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_7: | 
|  | 257 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 258 | define void @s_test_umed3_i32_pat_7(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 259 | bb: | 
|  | 260 | %tmp0 = call i32 @umin(i32 %y, i32 %x) | 
|  | 261 | %tmp1 = call i32 @umax(i32 %y, i32 %x) | 
|  | 262 | %tmp2 = call i32 @umin(i32 %z, i32 %tmp1) | 
|  | 263 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 264 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 265 | ret void | 
|  | 266 | } | 
|  | 267 |  | 
|  | 268 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_8: | 
|  | 269 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 270 | define void @s_test_umed3_i32_pat_8(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 271 | bb: | 
|  | 272 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 273 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 274 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 275 | %tmp3 = call i32 @umax(i32 %tmp2, i32 %tmp0) | 
|  | 276 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 277 | ret void | 
|  | 278 | } | 
|  | 279 |  | 
|  | 280 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_9: | 
|  | 281 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 282 | define void @s_test_umed3_i32_pat_9(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 283 | bb: | 
|  | 284 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 285 | %tmp1 = call i32 @umax(i32 %y, i32 %x) | 
|  | 286 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 287 | %tmp3 = call i32 @umax(i32 %tmp2, i32 %tmp0) | 
|  | 288 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 289 | ret void | 
|  | 290 | } | 
|  | 291 |  | 
|  | 292 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_10: | 
|  | 293 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 294 | define void @s_test_umed3_i32_pat_10(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 295 | bb: | 
|  | 296 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 297 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 298 | %tmp2 = call i32 @umin(i32 %z, i32 %tmp1) | 
|  | 299 | %tmp3 = call i32 @umax(i32 %tmp2, i32 %tmp0) | 
|  | 300 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 301 | ret void | 
|  | 302 | } | 
|  | 303 |  | 
|  | 304 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_11: | 
|  | 305 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 306 | define void @s_test_umed3_i32_pat_11(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 307 | bb: | 
|  | 308 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 309 | %tmp1 = call i32 @umax(i32 %y, i32 %x) | 
|  | 310 | %tmp2 = call i32 @umin(i32 %z, i32 %tmp1) | 
|  | 311 | %tmp3 = call i32 @umax(i32 %tmp2, i32 %tmp0) | 
|  | 312 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 313 | ret void | 
|  | 314 | } | 
|  | 315 |  | 
|  | 316 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_12: | 
|  | 317 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 318 | define void @s_test_umed3_i32_pat_12(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 319 | bb: | 
|  | 320 | %tmp0 = call i32 @umin(i32 %y, i32 %x) | 
|  | 321 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 322 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 323 | %tmp3 = call i32 @umax(i32 %tmp2, i32 %tmp0) | 
|  | 324 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 325 | ret void | 
|  | 326 | } | 
|  | 327 |  | 
|  | 328 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_13: | 
|  | 329 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 330 | define void @s_test_umed3_i32_pat_13(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 331 | bb: | 
|  | 332 | %tmp0 = call i32 @umin(i32 %y, i32 %x) | 
|  | 333 | %tmp1 = call i32 @umax(i32 %y, i32 %x) | 
|  | 334 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 335 | %tmp3 = call i32 @umax(i32 %tmp2, i32 %tmp0) | 
|  | 336 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 337 | ret void | 
|  | 338 | } | 
|  | 339 |  | 
|  | 340 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_14: | 
|  | 341 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 342 | define void @s_test_umed3_i32_pat_14(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 343 | bb: | 
|  | 344 | %tmp0 = call i32 @umin(i32 %y, i32 %x) | 
|  | 345 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 346 | %tmp2 = call i32 @umin(i32 %z, i32 %tmp1) | 
|  | 347 | %tmp3 = call i32 @umax(i32 %tmp2, i32 %tmp0) | 
|  | 348 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 349 | ret void | 
|  | 350 | } | 
|  | 351 |  | 
|  | 352 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_15: | 
|  | 353 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 354 | define void @s_test_umed3_i32_pat_15(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 355 | bb: | 
|  | 356 | %tmp0 = call i32 @umin(i32 %y, i32 %x) | 
|  | 357 | %tmp1 = call i32 @umax(i32 %y, i32 %x) | 
|  | 358 | %tmp2 = call i32 @umin(i32 %z, i32 %tmp1) | 
|  | 359 | %tmp3 = call i32 @umax(i32 %tmp2, i32 %tmp0) | 
|  | 360 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 361 | ret void | 
|  | 362 | } | 
|  | 363 |  | 
|  | 364 | ; GCN-LABEL: {{^}}s_test_umed3_i16_pat_0: | 
|  | 365 | ; GCN: s_and_b32 | 
|  | 366 | ; GCN: s_and_b32 | 
|  | 367 | ; GCN: s_and_b32 | 
|  | 368 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 369 | define void @s_test_umed3_i16_pat_0(i16 addrspace(1)* %arg, i16 %x, i16 %y, i16 %z) #1 { | 
|  | 370 | bb: | 
|  | 371 | %tmp0 = call i16 @umin16(i16 %x, i16 %y) | 
|  | 372 | %tmp1 = call i16 @umax16(i16 %x, i16 %y) | 
|  | 373 | %tmp2 = call i16 @umin16(i16 %tmp1, i16 %z) | 
|  | 374 | %tmp3 = call i16 @umax16(i16 %tmp0, i16 %tmp2) | 
|  | 375 | store i16 %tmp3, i16 addrspace(1)* %arg | 
|  | 376 | ret void | 
|  | 377 | } | 
|  | 378 |  | 
|  | 379 | ; GCN-LABEL: {{^}}s_test_umed3_i8_pat_0: | 
|  | 380 | ; GCN: s_and_b32 | 
|  | 381 | ; GCN: s_and_b32 | 
|  | 382 | ; GCN: s_and_b32 | 
|  | 383 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 384 | define void @s_test_umed3_i8_pat_0(i8 addrspace(1)* %arg, i8 %x, i8 %y, i8 %z) #1 { | 
|  | 385 | bb: | 
|  | 386 | %tmp0 = call i8 @umin8(i8 %x, i8 %y) | 
|  | 387 | %tmp1 = call i8 @umax8(i8 %x, i8 %y) | 
|  | 388 | %tmp2 = call i8 @umin8(i8 %tmp1, i8 %z) | 
|  | 389 | %tmp3 = call i8 @umax8(i8 %tmp0, i8 %tmp2) | 
|  | 390 | store i8 %tmp3, i8 addrspace(1)* %arg | 
|  | 391 | ret void | 
|  | 392 | } | 
|  | 393 |  | 
|  | 394 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_0_multi_use_0: | 
|  | 395 | ; GCN-NOT: v_med3_u32 | 
|  | 396 | define void @s_test_umed3_i32_pat_0_multi_use_0(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 397 | bb: | 
|  | 398 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 399 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 400 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 401 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 402 | store volatile i32 %tmp0, i32 addrspace(1)* %arg | 
|  | 403 | store volatile i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 404 | ret void | 
|  | 405 | } | 
|  | 406 |  | 
|  | 407 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_0_multi_use_1: | 
|  | 408 | ; GCN-NOT: v_med3_u32 | 
|  | 409 | define void @s_test_umed3_i32_pat_0_multi_use_1(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 410 | bb: | 
|  | 411 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 412 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 413 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 414 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 415 | store volatile i32 %tmp1, i32 addrspace(1)* %arg | 
|  | 416 | store volatile i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 417 | ret void | 
|  | 418 | } | 
|  | 419 |  | 
|  | 420 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_0_multi_use_2: | 
|  | 421 | ; GCN-NOT: v_med3_u32 | 
|  | 422 | define void @s_test_umed3_i32_pat_0_multi_use_2(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 423 | bb: | 
|  | 424 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 425 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 426 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 427 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 428 | store volatile i32 %tmp2, i32 addrspace(1)* %arg | 
|  | 429 | store volatile i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 430 | ret void | 
|  | 431 | } | 
|  | 432 |  | 
|  | 433 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_0_multi_use_result: | 
|  | 434 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} | 
|  | 435 | define void @s_test_umed3_i32_pat_0_multi_use_result(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 436 | bb: | 
|  | 437 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 438 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 439 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 440 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 441 | store volatile i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 442 | store volatile i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 443 | ret void | 
|  | 444 | } | 
|  | 445 |  | 
|  | 446 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_0_imm_src0: | 
|  | 447 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, 1, v{{[0-9]+}} | 
|  | 448 | define void @s_test_umed3_i32_pat_0_imm_src0(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 449 | bb: | 
|  | 450 | %tmp0 = call i32 @umin(i32 1, i32 %y) | 
|  | 451 | %tmp1 = call i32 @umax(i32 1, i32 %y) | 
|  | 452 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 453 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 454 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 455 | ret void | 
|  | 456 | } | 
|  | 457 |  | 
|  | 458 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_0_imm_src1: | 
|  | 459 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, 2, v{{[0-9]+}} | 
|  | 460 | define void @s_test_umed3_i32_pat_0_imm_src1(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 461 | bb: | 
|  | 462 | %tmp0 = call i32 @umin(i32 %x, i32 2) | 
|  | 463 | %tmp1 = call i32 @umax(i32 %x, i32 2) | 
|  | 464 | %tmp2 = call i32 @umin(i32 %tmp1, i32 %z) | 
|  | 465 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 466 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 467 | ret void | 
|  | 468 | } | 
|  | 469 |  | 
|  | 470 | ; GCN-LABEL: {{^}}s_test_umed3_i32_pat_0_imm_src2: | 
|  | 471 | ; GCN: v_med3_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, 9 | 
|  | 472 | define void @s_test_umed3_i32_pat_0_imm_src2(i32 addrspace(1)* %arg, i32 %x, i32 %y, i32 %z) #1 { | 
|  | 473 | bb: | 
|  | 474 | %tmp0 = call i32 @umin(i32 %x, i32 %y) | 
|  | 475 | %tmp1 = call i32 @umax(i32 %x, i32 %y) | 
|  | 476 | %tmp2 = call i32 @umin(i32 %tmp1, i32 9) | 
|  | 477 | %tmp3 = call i32 @umax(i32 %tmp0, i32 %tmp2) | 
|  | 478 | store i32 %tmp3, i32 addrspace(1)* %arg | 
|  | 479 | ret void | 
|  | 480 | } | 
|  | 481 |  | 
| Matt Arsenault | f639c32 | 2016-01-28 20:53:42 +0000 | [diff] [blame] | 482 | attributes #0 = { nounwind readnone } | 
|  | 483 | attributes #1 = { nounwind } | 
| Matt Arsenault | c89f291 | 2016-03-07 21:54:48 +0000 | [diff] [blame] | 484 | attributes #2 = { nounwind readnone alwaysinline } |