llvm/llvm/test/Analysis/CostModel/AMDGPU/ptrmask.ll

; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck -check-prefixes=ALL %s
; RUN: opt -passes="print<cost-model>" -cost-kind=code-size 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck -check-prefixes=ALL-SIZE %s
; END.

define ptr @ptrmask_p0_i64(ptr %ptr, i64 %mask) {
; ALL-LABEL: 'ptrmask_p0_i64'
; ALL-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr @llvm.ptrmask.p0.i64(ptr %ptr, i64 %mask)
; ALL-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret ptr %result
;
; ALL-SIZE-LABEL: 'ptrmask_p0_i64'
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr @llvm.ptrmask.p0.i64(ptr %ptr, i64 %mask)
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret ptr %result
;
  %result = call ptr @llvm.ptrmask.p0.i64(ptr %ptr, i64 %mask)
  ret ptr %result
}

define <2 x ptr> @ptrmask_v2p0_v2i64(<2 x ptr> %ptr, <2 x i64> %mask) {
; ALL-LABEL: 'ptrmask_v2p0_v2i64'
; ALL-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %result = call <2 x ptr> @llvm.ptrmask.v2p0.v2i64(<2 x ptr> %ptr, <2 x i64> %mask)
; ALL-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret <2 x ptr> %result
;
; ALL-SIZE-LABEL: 'ptrmask_v2p0_v2i64'
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %result = call <2 x ptr> @llvm.ptrmask.v2p0.v2i64(<2 x ptr> %ptr, <2 x i64> %mask)
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret <2 x ptr> %result
;
  %result = call <2 x ptr> @llvm.ptrmask.v2p0.v2i64(<2 x ptr> %ptr, <2 x i64> %mask)
  ret <2 x ptr> %result
}

define ptr addrspace(1) @ptrmask_p1_i64(ptr addrspace(1) %ptr, i64 %mask) {
; ALL-LABEL: 'ptrmask_p1_i64'
; ALL-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) %ptr, i64 %mask)
; ALL-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret ptr addrspace(1) %result
;
; ALL-SIZE-LABEL: 'ptrmask_p1_i64'
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) %ptr, i64 %mask)
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret ptr addrspace(1) %result
;
  %result = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) %ptr, i64 %mask)
  ret ptr addrspace(1) %result
}

define ptr addrspace(5) @ptrmask_p5_i32(ptr addrspace(5) %ptr, i32 %mask) {
; ALL-LABEL: 'ptrmask_p5_i32'
; ALL-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr addrspace(5) @llvm.ptrmask.p5.i32(ptr addrspace(5) %ptr, i32 %mask)
; ALL-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret ptr addrspace(5) %result
;
; ALL-SIZE-LABEL: 'ptrmask_p5_i32'
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr addrspace(5) @llvm.ptrmask.p5.i32(ptr addrspace(5) %ptr, i32 %mask)
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret ptr addrspace(5) %result
;
  %result = call ptr addrspace(5) @llvm.ptrmask.p5.i32(ptr addrspace(5) %ptr, i32 %mask)
  ret ptr addrspace(5) %result
}

define ptr addrspace(3) @ptrmask_p3_i32(ptr addrspace(3) %ptr, i32 %mask) {
; ALL-LABEL: 'ptrmask_p3_i32'
; ALL-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) %ptr, i32 %mask)
; ALL-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret ptr addrspace(3) %result
;
; ALL-SIZE-LABEL: 'ptrmask_p3_i32'
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) %ptr, i32 %mask)
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret ptr addrspace(3) %result
;
  %result = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) %ptr, i32 %mask)
  ret ptr addrspace(3) %result
}

define <2 x ptr addrspace(5)> @ptrmask_v2p5_v2i32(<2 x ptr addrspace(5)> %ptr, <2 x i32> %mask) {
; ALL-LABEL: 'ptrmask_v2p5_v2i32'
; ALL-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %result = call <2 x ptr addrspace(5)> @llvm.ptrmask.v2p5.v2i32(<2 x ptr addrspace(5)> %ptr, <2 x i32> %mask)
; ALL-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret <2 x ptr addrspace(5)> %result
;
; ALL-SIZE-LABEL: 'ptrmask_v2p5_v2i32'
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %result = call <2 x ptr addrspace(5)> @llvm.ptrmask.v2p5.v2i32(<2 x ptr addrspace(5)> %ptr, <2 x i32> %mask)
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret <2 x ptr addrspace(5)> %result
;
  %result = call <2 x ptr addrspace(5)> @llvm.ptrmask.v2p5.v2i32(<2 x ptr addrspace(5)> %ptr, <2 x i32> %mask)
  ret <2 x ptr addrspace(5)> %result
}

define <3 x ptr> @ptrmask_v3p0_v3i64(<3 x ptr> %ptr, <3 x i64> %mask) {
; ALL-LABEL: 'ptrmask_v3p0_v3i64'
; ALL-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %result = call <3 x ptr> @llvm.ptrmask.v3p0.v3i64(<3 x ptr> %ptr, <3 x i64> %mask)
; ALL-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret <3 x ptr> %result
;
; ALL-SIZE-LABEL: 'ptrmask_v3p0_v3i64'
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %result = call <3 x ptr> @llvm.ptrmask.v3p0.v3i64(<3 x ptr> %ptr, <3 x i64> %mask)
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret <3 x ptr> %result
;
  %result = call <3 x ptr> @llvm.ptrmask.v3p0.v3i64(<3 x ptr> %ptr, <3 x i64> %mask)
  ret <3 x ptr> %result
}

define <3 x ptr addrspace(5)> @ptrmask_v3p5_v3i32(<3 x ptr addrspace(5)> %ptr, <3 x i32> %mask) {
; ALL-LABEL: 'ptrmask_v3p5_v3i32'
; ALL-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %result = call <3 x ptr addrspace(5)> @llvm.ptrmask.v3p5.v3i32(<3 x ptr addrspace(5)> %ptr, <3 x i32> %mask)
; ALL-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret <3 x ptr addrspace(5)> %result
;
; ALL-SIZE-LABEL: 'ptrmask_v3p5_v3i32'
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %result = call <3 x ptr addrspace(5)> @llvm.ptrmask.v3p5.v3i32(<3 x ptr addrspace(5)> %ptr, <3 x i32> %mask)
; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret <3 x ptr addrspace(5)> %result
;
  %result = call <3 x ptr addrspace(5)> @llvm.ptrmask.v3p5.v3i32(<3 x ptr addrspace(5)> %ptr, <3 x i32> %mask)
  ret <3 x ptr addrspace(5)> %result
}