1; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 2; RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -verify-machineinstrs -stop-after=irtranslator < %s | FileCheck %s 3 4define i8* @ptrmask_flat_i64(i8* %ptr, i64 %mask) { 5 ; CHECK-LABEL: name: ptrmask_flat_i64 6 ; CHECK: bb.1 (%ir-block.0): 7 ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3, $sgpr30_sgpr31 8 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 9 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 10 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr2 11 ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY $vgpr3 12 ; CHECK: [[COPY4:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31 13 ; CHECK: [[MV:%[0-9]+]]:_(p0) = G_MERGE_VALUES [[COPY]](s32), [[COPY1]](s32) 14 ; CHECK: [[MV1:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY2]](s32), [[COPY3]](s32) 15 ; CHECK: [[PTRMASK:%[0-9]+]]:_(p0) = G_PTRMASK [[MV]], [[MV1]](s64) 16 ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[PTRMASK]](p0) 17 ; CHECK: $vgpr0 = COPY [[UV]](s32) 18 ; CHECK: $vgpr1 = COPY [[UV1]](s32) 19 ; CHECK: [[COPY5:%[0-9]+]]:ccr_sgpr_64 = COPY [[COPY4]] 20 ; CHECK: S_SETPC_B64_return [[COPY5]], implicit $vgpr0, implicit $vgpr1 21 %masked = call i8* @llvm.ptrmask.p0i8.i64(i8* %ptr, i64 %mask) 22 ret i8* %masked 23} 24 25define i8* @ptrmask_flat_i32(i8* %ptr, i32 %mask) { 26 ; CHECK-LABEL: name: ptrmask_flat_i32 27 ; CHECK: bb.1 (%ir-block.0): 28 ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr30_sgpr31 29 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 30 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 31 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr2 32 ; CHECK: [[COPY3:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31 33 ; CHECK: [[MV:%[0-9]+]]:_(p0) = G_MERGE_VALUES [[COPY]](s32), [[COPY1]](s32) 34 ; CHECK: [[PTRMASK:%[0-9]+]]:_(p0) = G_PTRMASK [[MV]], [[COPY2]](s32) 35 ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[PTRMASK]](p0) 36 ; CHECK: $vgpr0 = COPY [[UV]](s32) 37 ; CHECK: $vgpr1 = COPY [[UV1]](s32) 38 ; CHECK: [[COPY4:%[0-9]+]]:ccr_sgpr_64 = COPY [[COPY3]] 39 ; CHECK: S_SETPC_B64_return [[COPY4]], implicit $vgpr0, implicit $vgpr1 40 %masked = call i8* @llvm.ptrmask.p0i8.i32(i8* %ptr, i32 %mask) 41 ret i8* %masked 42} 43 44define i8* @ptrmask_flat_i16(i8* %ptr, i16 %mask) { 45 ; CHECK-LABEL: name: ptrmask_flat_i16 46 ; CHECK: bb.1 (%ir-block.0): 47 ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr30_sgpr31 48 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 49 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 50 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr2 51 ; CHECK: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY2]](s32) 52 ; CHECK: [[COPY3:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31 53 ; CHECK: [[MV:%[0-9]+]]:_(p0) = G_MERGE_VALUES [[COPY]](s32), [[COPY1]](s32) 54 ; CHECK: [[PTRMASK:%[0-9]+]]:_(p0) = G_PTRMASK [[MV]], [[TRUNC]](s16) 55 ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[PTRMASK]](p0) 56 ; CHECK: $vgpr0 = COPY [[UV]](s32) 57 ; CHECK: $vgpr1 = COPY [[UV1]](s32) 58 ; CHECK: [[COPY4:%[0-9]+]]:ccr_sgpr_64 = COPY [[COPY3]] 59 ; CHECK: S_SETPC_B64_return [[COPY4]], implicit $vgpr0, implicit $vgpr1 60 %masked = call i8* @llvm.ptrmask.p0i8.i16(i8* %ptr, i16 %mask) 61 ret i8* %masked 62} 63 64define i8* @ptrmask_flat_i1(i8* %ptr, i1 %mask) { 65 ; CHECK-LABEL: name: ptrmask_flat_i1 66 ; CHECK: bb.1 (%ir-block.0): 67 ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr30_sgpr31 68 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0 69 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 70 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr2 71 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[COPY2]](s32) 72 ; CHECK: [[COPY3:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31 73 ; CHECK: [[MV:%[0-9]+]]:_(p0) = G_MERGE_VALUES [[COPY]](s32), [[COPY1]](s32) 74 ; CHECK: [[PTRMASK:%[0-9]+]]:_(p0) = G_PTRMASK [[MV]], [[TRUNC]](s1) 75 ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[PTRMASK]](p0) 76 ; CHECK: $vgpr0 = COPY [[UV]](s32) 77 ; CHECK: $vgpr1 = COPY [[UV1]](s32) 78 ; CHECK: [[COPY4:%[0-9]+]]:ccr_sgpr_64 = COPY [[COPY3]] 79 ; CHECK: S_SETPC_B64_return [[COPY4]], implicit $vgpr0, implicit $vgpr1 80 %masked = call i8* @llvm.ptrmask.p0i8.i1(i8* %ptr, i1 %mask) 81 ret i8* %masked 82} 83 84define i8 addrspace(3)* @ptrmask_local_i64(i8 addrspace(3)* %ptr, i64 %mask) { 85 ; CHECK-LABEL: name: ptrmask_local_i64 86 ; CHECK: bb.1 (%ir-block.0): 87 ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr30_sgpr31 88 ; CHECK: [[COPY:%[0-9]+]]:_(p3) = COPY $vgpr0 89 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 90 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr2 91 ; CHECK: [[COPY3:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31 92 ; CHECK: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY1]](s32), [[COPY2]](s32) 93 ; CHECK: [[PTRMASK:%[0-9]+]]:_(p3) = G_PTRMASK [[COPY]], [[MV]](s64) 94 ; CHECK: $vgpr0 = COPY [[PTRMASK]](p3) 95 ; CHECK: [[COPY4:%[0-9]+]]:ccr_sgpr_64 = COPY [[COPY3]] 96 ; CHECK: S_SETPC_B64_return [[COPY4]], implicit $vgpr0 97 %masked = call i8 addrspace(3)* @llvm.ptrmask.p3i8.i64(i8 addrspace(3)* %ptr, i64 %mask) 98 ret i8 addrspace(3)* %masked 99} 100 101define i8 addrspace(3)* @ptrmask_local_i32(i8 addrspace(3)* %ptr, i32 %mask) { 102 ; CHECK-LABEL: name: ptrmask_local_i32 103 ; CHECK: bb.1 (%ir-block.0): 104 ; CHECK: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31 105 ; CHECK: [[COPY:%[0-9]+]]:_(p3) = COPY $vgpr0 106 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 107 ; CHECK: [[COPY2:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31 108 ; CHECK: [[PTRMASK:%[0-9]+]]:_(p3) = G_PTRMASK [[COPY]], [[COPY1]](s32) 109 ; CHECK: $vgpr0 = COPY [[PTRMASK]](p3) 110 ; CHECK: [[COPY3:%[0-9]+]]:ccr_sgpr_64 = COPY [[COPY2]] 111 ; CHECK: S_SETPC_B64_return [[COPY3]], implicit $vgpr0 112 %masked = call i8 addrspace(3)* @llvm.ptrmask.p3i8.i32(i8 addrspace(3)* %ptr, i32 %mask) 113 ret i8 addrspace(3)* %masked 114} 115 116define i8 addrspace(3)* @ptrmask_local_i16(i8 addrspace(3)* %ptr, i16 %mask) { 117 ; CHECK-LABEL: name: ptrmask_local_i16 118 ; CHECK: bb.1 (%ir-block.0): 119 ; CHECK: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31 120 ; CHECK: [[COPY:%[0-9]+]]:_(p3) = COPY $vgpr0 121 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 122 ; CHECK: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY1]](s32) 123 ; CHECK: [[COPY2:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31 124 ; CHECK: [[PTRMASK:%[0-9]+]]:_(p3) = G_PTRMASK [[COPY]], [[TRUNC]](s16) 125 ; CHECK: $vgpr0 = COPY [[PTRMASK]](p3) 126 ; CHECK: [[COPY3:%[0-9]+]]:ccr_sgpr_64 = COPY [[COPY2]] 127 ; CHECK: S_SETPC_B64_return [[COPY3]], implicit $vgpr0 128 %masked = call i8 addrspace(3)* @llvm.ptrmask.p3i8.i16(i8 addrspace(3)* %ptr, i16 %mask) 129 ret i8 addrspace(3)* %masked 130} 131 132define i8 addrspace(3)* @ptrmask_local_i1(i8 addrspace(3)* %ptr, i1 %mask) { 133 ; CHECK-LABEL: name: ptrmask_local_i1 134 ; CHECK: bb.1 (%ir-block.0): 135 ; CHECK: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31 136 ; CHECK: [[COPY:%[0-9]+]]:_(p3) = COPY $vgpr0 137 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1 138 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[COPY1]](s32) 139 ; CHECK: [[COPY2:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31 140 ; CHECK: [[PTRMASK:%[0-9]+]]:_(p3) = G_PTRMASK [[COPY]], [[TRUNC]](s1) 141 ; CHECK: $vgpr0 = COPY [[PTRMASK]](p3) 142 ; CHECK: [[COPY3:%[0-9]+]]:ccr_sgpr_64 = COPY [[COPY2]] 143 ; CHECK: S_SETPC_B64_return [[COPY3]], implicit $vgpr0 144 %masked = call i8 addrspace(3)* @llvm.ptrmask.p3i8.i1(i8 addrspace(3)* %ptr, i1 %mask) 145 ret i8 addrspace(3)* %masked 146} 147 148; Seems to not work 149; define <2 x i8*> @ptrmask_flat_i64_v2(<2 x i8*> %ptr, <2 x i64> %mask) { 150; %masked = call <2 x i8*> @llvm.ptrmask.v2p0i8.v2i64(<2 x i8*> %ptr, <2 x i64> %mask) 151; ret <2 x i8*> %masked 152; } 153 154declare i8* @llvm.ptrmask.p0i8.i64(i8*, i64) 155declare i8* @llvm.ptrmask.p0i8.i32(i8*, i32) 156declare i8* @llvm.ptrmask.p0i8.i16(i8*, i16) 157declare i8* @llvm.ptrmask.p0i8.i1(i8*, i1) 158declare i8 addrspace(3)* @llvm.ptrmask.p3i8.i64(i8 addrspace(3)*, i64) 159declare i8 addrspace(3)* @llvm.ptrmask.p3i8.i32(i8 addrspace(3)*, i32) 160declare i8 addrspace(3)* @llvm.ptrmask.p3i8.i16(i8 addrspace(3)*, i16) 161declare i8 addrspace(3)* @llvm.ptrmask.p3i8.i1(i8 addrspace(3)*, i1) 162