Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s |
Tom Stellard | 49f8bfd | 2015-01-06 18:00:21 +0000 | [diff] [blame] | 2 | ; RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s |
Marek Olsak | 7517077 | 2015-01-27 17:27:15 +0000 | [diff] [blame] | 3 | ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 4 | |
Matt Arsenault | 28bd7d4 | 2015-09-25 18:21:47 +0000 | [diff] [blame] | 5 | declare i32 @llvm.r600.read.tidig.x() #0 |
| 6 | |
Tom Stellard | 79243d9 | 2014-10-01 17:15:17 +0000 | [diff] [blame] | 7 | ; FUNC-LABEL: {{^}}test2: |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 8 | ; EG: AND_INT {{\*? *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} |
| 9 | ; EG: AND_INT {{\*? *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 10 | |
Tom Stellard | 326d6ec | 2014-11-05 14:50:53 +0000 | [diff] [blame] | 11 | ; SI: v_and_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}} |
| 12 | ; SI: v_and_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}} |
Aaron Watry | 00aeb11 | 2013-06-25 13:55:23 +0000 | [diff] [blame] | 13 | |
| 14 | define void @test2(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %in) { |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 15 | %b_ptr = getelementptr <2 x i32>, <2 x i32> addrspace(1)* %in, i32 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 16 | %a = load <2 x i32>, <2 x i32> addrspace(1) * %in |
| 17 | %b = load <2 x i32>, <2 x i32> addrspace(1) * %b_ptr |
Aaron Watry | 00aeb11 | 2013-06-25 13:55:23 +0000 | [diff] [blame] | 18 | %result = and <2 x i32> %a, %b |
| 19 | store <2 x i32> %result, <2 x i32> addrspace(1)* %out |
| 20 | ret void |
| 21 | } |
| 22 | |
Tom Stellard | 79243d9 | 2014-10-01 17:15:17 +0000 | [diff] [blame] | 23 | ; FUNC-LABEL: {{^}}test4: |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 24 | ; EG: AND_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} |
| 25 | ; EG: AND_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} |
| 26 | ; EG: AND_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} |
| 27 | ; EG: AND_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}} |
Aaron Watry | 00aeb11 | 2013-06-25 13:55:23 +0000 | [diff] [blame] | 28 | |
Tom Stellard | 326d6ec | 2014-11-05 14:50:53 +0000 | [diff] [blame] | 29 | ; SI: v_and_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}} |
| 30 | ; SI: v_and_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}} |
| 31 | ; SI: v_and_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}} |
| 32 | ; SI: v_and_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}} |
Aaron Watry | 00aeb11 | 2013-06-25 13:55:23 +0000 | [diff] [blame] | 33 | |
| 34 | define void @test4(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) { |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 35 | %b_ptr = getelementptr <4 x i32>, <4 x i32> addrspace(1)* %in, i32 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 36 | %a = load <4 x i32>, <4 x i32> addrspace(1) * %in |
| 37 | %b = load <4 x i32>, <4 x i32> addrspace(1) * %b_ptr |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 38 | %result = and <4 x i32> %a, %b |
| 39 | store <4 x i32> %result, <4 x i32> addrspace(1)* %out |
| 40 | ret void |
| 41 | } |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 42 | |
Tom Stellard | 79243d9 | 2014-10-01 17:15:17 +0000 | [diff] [blame] | 43 | ; FUNC-LABEL: {{^}}s_and_i32: |
Tom Stellard | 326d6ec | 2014-11-05 14:50:53 +0000 | [diff] [blame] | 44 | ; SI: s_and_b32 |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 45 | define void @s_and_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) { |
| 46 | %and = and i32 %a, %b |
| 47 | store i32 %and, i32 addrspace(1)* %out, align 4 |
| 48 | ret void |
| 49 | } |
| 50 | |
Tom Stellard | 79243d9 | 2014-10-01 17:15:17 +0000 | [diff] [blame] | 51 | ; FUNC-LABEL: {{^}}s_and_constant_i32: |
Tom Stellard | 326d6ec | 2014-11-05 14:50:53 +0000 | [diff] [blame] | 52 | ; SI: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0x12d687 |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 53 | define void @s_and_constant_i32(i32 addrspace(1)* %out, i32 %a) { |
| 54 | %and = and i32 %a, 1234567 |
| 55 | store i32 %and, i32 addrspace(1)* %out, align 4 |
| 56 | ret void |
| 57 | } |
| 58 | |
Matt Arsenault | 28bd7d4 | 2015-09-25 18:21:47 +0000 | [diff] [blame] | 59 | ; FIXME: We should really duplicate the constant so that the SALU use |
| 60 | ; can fold into the s_and_b32 and the VALU one is materialized |
| 61 | ; directly without copying from the SGPR. |
| 62 | |
| 63 | ; Second use is a VGPR use of the constant. |
| 64 | ; FUNC-LABEL: {{^}}s_and_multi_use_constant_i32_0: |
| 65 | ; SI: s_mov_b32 [[K:s[0-9]+]], 0x12d687 |
| 66 | ; SI-DAG: s_and_b32 [[AND:s[0-9]+]], s{{[0-9]+}}, [[K]] |
| 67 | ; SI-DAG: v_mov_b32_e32 [[VK:v[0-9]+]], [[K]] |
| 68 | ; SI: buffer_store_dword [[VK]] |
| 69 | define void @s_and_multi_use_constant_i32_0(i32 addrspace(1)* %out, i32 %a, i32 %b) { |
| 70 | %and = and i32 %a, 1234567 |
| 71 | |
| 72 | ; Just to stop future replacement of copy to vgpr + store with VALU op. |
| 73 | %foo = add i32 %and, %b |
| 74 | store volatile i32 %foo, i32 addrspace(1)* %out |
| 75 | store volatile i32 1234567, i32 addrspace(1)* %out |
| 76 | ret void |
| 77 | } |
| 78 | |
| 79 | ; Second use is another SGPR use of the constant. |
| 80 | ; FUNC-LABEL: {{^}}s_and_multi_use_constant_i32_1: |
| 81 | ; SI: s_mov_b32 [[K:s[0-9]+]], 0x12d687 |
| 82 | ; SI: s_and_b32 [[AND:s[0-9]+]], s{{[0-9]+}}, [[K]] |
| 83 | ; SI: s_add_i32 |
| 84 | ; SI: s_add_i32 [[ADD:s[0-9]+]], s{{[0-9]+}}, [[K]] |
| 85 | ; SI: buffer_store_dword [[VK]] |
| 86 | define void @s_and_multi_use_constant_i32_1(i32 addrspace(1)* %out, i32 %a, i32 %b) { |
| 87 | %and = and i32 %a, 1234567 |
| 88 | %foo = add i32 %and, 1234567 |
| 89 | %bar = add i32 %foo, %b |
| 90 | store volatile i32 %bar, i32 addrspace(1)* %out |
| 91 | ret void |
| 92 | } |
| 93 | |
| 94 | ; FUNC-LABEL: {{^}}v_and_i32_vgpr_vgpr: |
| 95 | ; SI: v_and_b32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} |
| 96 | define void @v_and_i32_vgpr_vgpr(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) { |
| 97 | %tid = call i32 @llvm.r600.read.tidig.x() #0 |
| 98 | %gep.a = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid |
| 99 | %gep.b = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid |
| 100 | %gep.out = getelementptr i32, i32 addrspace(1)* %out, i32 %tid |
| 101 | %a = load i32, i32 addrspace(1)* %gep.a |
| 102 | %b = load i32, i32 addrspace(1)* %gep.b |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 103 | %and = and i32 %a, %b |
Matt Arsenault | 28bd7d4 | 2015-09-25 18:21:47 +0000 | [diff] [blame] | 104 | store i32 %and, i32 addrspace(1)* %gep.out |
| 105 | ret void |
| 106 | } |
| 107 | |
| 108 | ; FUNC-LABEL: {{^}}v_and_i32_sgpr_vgpr: |
| 109 | ; SI-DAG: s_load_dword [[SA:s[0-9]+]] |
| 110 | ; SI-DAG: {{buffer|flat}}_load_dword [[VB:v[0-9]+]] |
| 111 | ; SI: v_and_b32_e32 v{{[0-9]+}}, [[SA]], [[VB]] |
| 112 | define void @v_and_i32_sgpr_vgpr(i32 addrspace(1)* %out, i32 %a, i32 addrspace(1)* %bptr) { |
| 113 | %tid = call i32 @llvm.r600.read.tidig.x() #0 |
| 114 | %gep.b = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid |
| 115 | %gep.out = getelementptr i32, i32 addrspace(1)* %out, i32 %tid |
| 116 | %b = load i32, i32 addrspace(1)* %gep.b |
| 117 | %and = and i32 %a, %b |
| 118 | store i32 %and, i32 addrspace(1)* %gep.out |
| 119 | ret void |
| 120 | } |
| 121 | |
| 122 | ; FUNC-LABEL: {{^}}v_and_i32_vgpr_sgpr: |
| 123 | ; SI-DAG: s_load_dword [[SA:s[0-9]+]] |
| 124 | ; SI-DAG: {{buffer|flat}}_load_dword [[VB:v[0-9]+]] |
| 125 | ; SI: v_and_b32_e32 v{{[0-9]+}}, [[SA]], [[VB]] |
| 126 | define void @v_and_i32_vgpr_sgpr(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 %b) { |
| 127 | %tid = call i32 @llvm.r600.read.tidig.x() #0 |
| 128 | %gep.a = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid |
| 129 | %gep.out = getelementptr i32, i32 addrspace(1)* %out, i32 %tid |
| 130 | %a = load i32, i32 addrspace(1)* %gep.a |
| 131 | %and = and i32 %a, %b |
| 132 | store i32 %and, i32 addrspace(1)* %gep.out |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 133 | ret void |
| 134 | } |
| 135 | |
Matt Arsenault | 11a4d67 | 2015-02-13 19:05:03 +0000 | [diff] [blame] | 136 | ; FUNC-LABEL: {{^}}v_and_constant_i32 |
| 137 | ; SI: v_and_b32_e32 v{{[0-9]+}}, 0x12d687, v{{[0-9]+}} |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 138 | define void @v_and_constant_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) { |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 139 | %a = load i32, i32 addrspace(1)* %aptr, align 4 |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 140 | %and = and i32 %a, 1234567 |
| 141 | store i32 %and, i32 addrspace(1)* %out, align 4 |
| 142 | ret void |
| 143 | } |
| 144 | |
Matt Arsenault | 11a4d67 | 2015-02-13 19:05:03 +0000 | [diff] [blame] | 145 | ; FUNC-LABEL: {{^}}v_and_inline_imm_64_i32 |
| 146 | ; SI: v_and_b32_e32 v{{[0-9]+}}, 64, v{{[0-9]+}} |
| 147 | define void @v_and_inline_imm_64_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) { |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 148 | %a = load i32, i32 addrspace(1)* %aptr, align 4 |
Matt Arsenault | 11a4d67 | 2015-02-13 19:05:03 +0000 | [diff] [blame] | 149 | %and = and i32 %a, 64 |
| 150 | store i32 %and, i32 addrspace(1)* %out, align 4 |
| 151 | ret void |
| 152 | } |
| 153 | |
| 154 | ; FUNC-LABEL: {{^}}v_and_inline_imm_neg_16_i32 |
| 155 | ; SI: v_and_b32_e32 v{{[0-9]+}}, -16, v{{[0-9]+}} |
| 156 | define void @v_and_inline_imm_neg_16_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) { |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 157 | %a = load i32, i32 addrspace(1)* %aptr, align 4 |
Matt Arsenault | 11a4d67 | 2015-02-13 19:05:03 +0000 | [diff] [blame] | 158 | %and = and i32 %a, -16 |
| 159 | store i32 %and, i32 addrspace(1)* %out, align 4 |
| 160 | ret void |
| 161 | } |
| 162 | |
| 163 | ; FUNC-LABEL: {{^}}s_and_i64 |
Tom Stellard | 326d6ec | 2014-11-05 14:50:53 +0000 | [diff] [blame] | 164 | ; SI: s_and_b64 |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 165 | define void @s_and_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) { |
| 166 | %and = and i64 %a, %b |
| 167 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 168 | ret void |
| 169 | } |
| 170 | |
Matt Arsenault | 0d89e84 | 2014-07-15 21:44:37 +0000 | [diff] [blame] | 171 | ; FIXME: Should use SGPRs |
Tom Stellard | 79243d9 | 2014-10-01 17:15:17 +0000 | [diff] [blame] | 172 | ; FUNC-LABEL: {{^}}s_and_i1: |
Tom Stellard | 326d6ec | 2014-11-05 14:50:53 +0000 | [diff] [blame] | 173 | ; SI: v_and_b32 |
Matt Arsenault | 0d89e84 | 2014-07-15 21:44:37 +0000 | [diff] [blame] | 174 | define void @s_and_i1(i1 addrspace(1)* %out, i1 %a, i1 %b) { |
| 175 | %and = and i1 %a, %b |
| 176 | store i1 %and, i1 addrspace(1)* %out |
| 177 | ret void |
| 178 | } |
| 179 | |
Matt Arsenault | 11a4d67 | 2015-02-13 19:05:03 +0000 | [diff] [blame] | 180 | ; FUNC-LABEL: {{^}}s_and_constant_i64 |
| 181 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}} |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 182 | define void @s_and_constant_i64(i64 addrspace(1)* %out, i64 %a) { |
| 183 | %and = and i64 %a, 281474976710655 |
| 184 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 185 | ret void |
| 186 | } |
| 187 | |
Tom Stellard | 79243d9 | 2014-10-01 17:15:17 +0000 | [diff] [blame] | 188 | ; FUNC-LABEL: {{^}}v_and_i64: |
Tom Stellard | 326d6ec | 2014-11-05 14:50:53 +0000 | [diff] [blame] | 189 | ; SI: v_and_b32 |
| 190 | ; SI: v_and_b32 |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 191 | define void @v_and_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr) { |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 192 | %a = load i64, i64 addrspace(1)* %aptr, align 8 |
| 193 | %b = load i64, i64 addrspace(1)* %bptr, align 8 |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 194 | %and = and i64 %a, %b |
| 195 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 196 | ret void |
| 197 | } |
| 198 | |
Tom Stellard | 79243d9 | 2014-10-01 17:15:17 +0000 | [diff] [blame] | 199 | ; FUNC-LABEL: {{^}}v_and_i64_br: |
Tom Stellard | 326d6ec | 2014-11-05 14:50:53 +0000 | [diff] [blame] | 200 | ; SI: v_and_b32 |
| 201 | ; SI: v_and_b32 |
Tom Stellard | 102c687 | 2014-09-03 15:22:41 +0000 | [diff] [blame] | 202 | define void @v_and_i64_br(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr, i32 %cond) { |
| 203 | entry: |
| 204 | %tmp0 = icmp eq i32 %cond, 0 |
| 205 | br i1 %tmp0, label %if, label %endif |
| 206 | |
| 207 | if: |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 208 | %a = load i64, i64 addrspace(1)* %aptr, align 8 |
| 209 | %b = load i64, i64 addrspace(1)* %bptr, align 8 |
Tom Stellard | 102c687 | 2014-09-03 15:22:41 +0000 | [diff] [blame] | 210 | %and = and i64 %a, %b |
| 211 | br label %endif |
| 212 | |
| 213 | endif: |
| 214 | %tmp1 = phi i64 [%and, %if], [0, %entry] |
| 215 | store i64 %tmp1, i64 addrspace(1)* %out, align 8 |
| 216 | ret void |
| 217 | } |
| 218 | |
Tom Stellard | 79243d9 | 2014-10-01 17:15:17 +0000 | [diff] [blame] | 219 | ; FUNC-LABEL: {{^}}v_and_constant_i64: |
Matt Arsenault | 68d9386 | 2015-09-24 08:36:14 +0000 | [diff] [blame] | 220 | ; SI-DAG: s_mov_b32 [[KLO:s[0-9]+]], 0xab19b207 |
| 221 | ; SI-DAG: s_movk_i32 [[KHI:s[0-9]+]], 0x11e{{$}} |
| 222 | ; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, [[KLO]], {{v[0-9]+}} |
| 223 | ; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, [[KHI]], {{v[0-9]+}} |
| 224 | ; SI: buffer_store_dwordx2 |
| 225 | define void @v_and_constant_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) { |
| 226 | %a = load i64, i64 addrspace(1)* %aptr, align 8 |
| 227 | %and = and i64 %a, 1231231234567 |
| 228 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 229 | ret void |
| 230 | } |
| 231 | |
| 232 | ; FIXME: Should replace and 0 |
| 233 | ; FUNC-LABEL: {{^}}v_and_i64_32_bit_constant: |
Tom Stellard | 326d6ec | 2014-11-05 14:50:53 +0000 | [diff] [blame] | 234 | ; SI: v_and_b32_e32 {{v[0-9]+}}, {{s[0-9]+}}, {{v[0-9]+}} |
Matt Arsenault | c8e2ce4 | 2015-09-24 07:16:37 +0000 | [diff] [blame] | 235 | ; SI: v_and_b32_e32 {{v[0-9]+}}, 0, {{v[0-9]+}} |
Matt Arsenault | 68d9386 | 2015-09-24 08:36:14 +0000 | [diff] [blame] | 236 | define void @v_and_i64_32_bit_constant(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) { |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 237 | %a = load i64, i64 addrspace(1)* %aptr, align 8 |
Matt Arsenault | 284ae08 | 2014-06-09 08:36:53 +0000 | [diff] [blame] | 238 | %and = and i64 %a, 1234567 |
| 239 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 240 | ret void |
| 241 | } |
Matt Arsenault | 49dd428 | 2014-09-15 17:15:02 +0000 | [diff] [blame] | 242 | |
| 243 | ; FIXME: Replace and 0 with mov 0 |
Tom Stellard | 79243d9 | 2014-10-01 17:15:17 +0000 | [diff] [blame] | 244 | ; FUNC-LABEL: {{^}}v_and_inline_imm_i64: |
Tom Stellard | 326d6ec | 2014-11-05 14:50:53 +0000 | [diff] [blame] | 245 | ; SI: v_and_b32_e32 {{v[0-9]+}}, 64, {{v[0-9]+}} |
| 246 | ; SI: v_and_b32_e32 {{v[0-9]+}}, 0, {{v[0-9]+}} |
Matt Arsenault | 49dd428 | 2014-09-15 17:15:02 +0000 | [diff] [blame] | 247 | define void @v_and_inline_imm_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) { |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 248 | %a = load i64, i64 addrspace(1)* %aptr, align 8 |
Matt Arsenault | 49dd428 | 2014-09-15 17:15:02 +0000 | [diff] [blame] | 249 | %and = and i64 %a, 64 |
| 250 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 251 | ret void |
| 252 | } |
| 253 | |
Matt Arsenault | 11a4d67 | 2015-02-13 19:05:03 +0000 | [diff] [blame] | 254 | ; FUNC-LABEL: {{^}}s_and_inline_imm_64_i64 |
Tom Stellard | 326d6ec | 2014-11-05 14:50:53 +0000 | [diff] [blame] | 255 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 64 |
Matt Arsenault | 11a4d67 | 2015-02-13 19:05:03 +0000 | [diff] [blame] | 256 | define void @s_and_inline_imm_64_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
Matt Arsenault | 49dd428 | 2014-09-15 17:15:02 +0000 | [diff] [blame] | 257 | %and = and i64 %a, 64 |
| 258 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 259 | ret void |
| 260 | } |
Matt Arsenault | 11a4d67 | 2015-02-13 19:05:03 +0000 | [diff] [blame] | 261 | |
| 262 | ; FUNC-LABEL: {{^}}s_and_inline_imm_1_i64 |
| 263 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 1 |
| 264 | define void @s_and_inline_imm_1_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 265 | %and = and i64 %a, 1 |
| 266 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 267 | ret void |
| 268 | } |
| 269 | |
| 270 | ; FUNC-LABEL: {{^}}s_and_inline_imm_1.0_i64 |
| 271 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 1.0 |
| 272 | define void @s_and_inline_imm_1.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 273 | %and = and i64 %a, 4607182418800017408 |
| 274 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 275 | ret void |
| 276 | } |
| 277 | |
| 278 | ; FUNC-LABEL: {{^}}s_and_inline_imm_neg_1.0_i64 |
| 279 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, -1.0 |
| 280 | define void @s_and_inline_imm_neg_1.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 281 | %and = and i64 %a, 13830554455654793216 |
| 282 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 283 | ret void |
| 284 | } |
| 285 | |
| 286 | ; FUNC-LABEL: {{^}}s_and_inline_imm_0.5_i64 |
| 287 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0.5 |
| 288 | define void @s_and_inline_imm_0.5_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 289 | %and = and i64 %a, 4602678819172646912 |
| 290 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 291 | ret void |
| 292 | } |
| 293 | |
| 294 | ; FUNC-LABEL: {{^}}s_and_inline_imm_neg_0.5_i64 |
| 295 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, -0.5 |
| 296 | define void @s_and_inline_imm_neg_0.5_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 297 | %and = and i64 %a, 13826050856027422720 |
| 298 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 299 | ret void |
| 300 | } |
| 301 | |
| 302 | ; FUNC-LABEL: {{^}}s_and_inline_imm_2.0_i64 |
| 303 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 2.0 |
| 304 | define void @s_and_inline_imm_2.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 305 | %and = and i64 %a, 4611686018427387904 |
| 306 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 307 | ret void |
| 308 | } |
| 309 | |
| 310 | ; FUNC-LABEL: {{^}}s_and_inline_imm_neg_2.0_i64 |
| 311 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, -2.0 |
| 312 | define void @s_and_inline_imm_neg_2.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 313 | %and = and i64 %a, 13835058055282163712 |
| 314 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 315 | ret void |
| 316 | } |
| 317 | |
| 318 | ; FUNC-LABEL: {{^}}s_and_inline_imm_4.0_i64 |
| 319 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 4.0 |
| 320 | define void @s_and_inline_imm_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 321 | %and = and i64 %a, 4616189618054758400 |
| 322 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 323 | ret void |
| 324 | } |
| 325 | |
| 326 | ; FUNC-LABEL: {{^}}s_and_inline_imm_neg_4.0_i64 |
| 327 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, -4.0 |
| 328 | define void @s_and_inline_imm_neg_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 329 | %and = and i64 %a, 13839561654909534208 |
| 330 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 331 | ret void |
| 332 | } |
| 333 | |
| 334 | |
| 335 | ; Test with the 64-bit integer bitpattern for a 32-bit float in the |
| 336 | ; low 32-bits, which is not a valid 64-bit inline immmediate. |
| 337 | |
| 338 | ; FUNC-LABEL: {{^}}s_and_inline_imm_f32_4.0_i64 |
| 339 | ; SI-DAG: s_mov_b32 s[[K_LO:[0-9]+]], 4.0 |
| 340 | ; SI-DAG: s_mov_b32 s[[K_HI:[0-9]+]], 0{{$}} |
| 341 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, s{{\[}}[[K_LO]]:[[K_HI]]{{\]}} |
| 342 | define void @s_and_inline_imm_f32_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 343 | %and = and i64 %a, 1082130432 |
| 344 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 345 | ret void |
| 346 | } |
| 347 | |
| 348 | ; FIXME: Copy of -1 register |
| 349 | ; FUNC-LABEL: {{^}}s_and_inline_imm_f32_neg_4.0_i64 |
| 350 | ; SI-DAG: s_mov_b32 s[[K_LO:[0-9]+]], -4.0 |
| 351 | ; SI-DAG: s_mov_b32 s[[K_HI:[0-9]+]], -1{{$}} |
| 352 | ; SI-DAG: s_mov_b32 s[[K_HI_COPY:[0-9]+]], s[[K_HI]] |
| 353 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, s{{\[}}[[K_LO]]:[[K_HI_COPY]]{{\]}} |
| 354 | define void @s_and_inline_imm_f32_neg_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 355 | %and = and i64 %a, -1065353216 |
| 356 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 357 | ret void |
| 358 | } |
| 359 | |
| 360 | ; Shift into upper 32-bits |
| 361 | ; FUNC-LABEL: {{^}}s_and_inline_high_imm_f32_4.0_i64 |
| 362 | ; SI-DAG: s_mov_b32 s[[K_HI:[0-9]+]], 4.0 |
| 363 | ; SI-DAG: s_mov_b32 s[[K_LO:[0-9]+]], 0{{$}} |
| 364 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, s{{\[}}[[K_LO]]:[[K_HI]]{{\]}} |
| 365 | define void @s_and_inline_high_imm_f32_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 366 | %and = and i64 %a, 4647714815446351872 |
| 367 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 368 | ret void |
| 369 | } |
| 370 | |
| 371 | ; FUNC-LABEL: {{^}}s_and_inline_high_imm_f32_neg_4.0_i64 |
| 372 | ; SI-DAG: s_mov_b32 s[[K_HI:[0-9]+]], -4.0 |
| 373 | ; SI-DAG: s_mov_b32 s[[K_LO:[0-9]+]], 0{{$}} |
| 374 | ; SI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, s{{\[}}[[K_LO]]:[[K_HI]]{{\]}} |
| 375 | define void @s_and_inline_high_imm_f32_neg_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) { |
| 376 | %and = and i64 %a, 13871086852301127680 |
| 377 | store i64 %and, i64 addrspace(1)* %out, align 8 |
| 378 | ret void |
| 379 | } |
Matt Arsenault | 28bd7d4 | 2015-09-25 18:21:47 +0000 | [diff] [blame] | 380 | |
| 381 | attributes #0 = { nounwind readnone } |