56 lines · plain
1; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s2 3;; The set of valid inputs for get_num_groups depends on the runtime NDRange,4;; but inputs outside of [0, 2] always return 1.5;; Here we assume Itanium mangling for function name.6declare i64 @_Z14get_num_groupsj(i32)7 8define i64 @foo(i32 %dim) {9 %x = call i64 @_Z14get_num_groupsj(i32 0)10 %y = call i64 @_Z14get_num_groupsj(i32 5)11 %acc = add i64 %x, %y12 %unknown = call i64 @_Z14get_num_groupsj(i32 %dim)13 %ret = add i64 %acc, %unknown14 ret i64 %ret15}16 17;; Capabilities:18; CHECK-DAG: OpCapability Kernel19; CHECK-DAG: OpCapability Int6420 21; CHECK-NOT: DAG-FENCE22 23;; Decorations:24; CHECK-DAG: OpDecorate %[[#GET_NUM_GROUPS:]] BuiltIn NumWorkgroups25; CHECK-DAG: OpDecorate %[[#GET_NUM_GROUPS]] Constant26 27; CHECK-NOT: DAG-FENCE28 29;; Types, Constants and Variables:30; CHECK-DAG: %[[#BOOL:]] = OpTypeBool31; CHECK-DAG: %[[#I32:]] = OpTypeInt 32 032; CHECK-DAG: %[[#I64:]] = OpTypeInt 64 033; CHECK-DAG: %[[#VEC:]] = OpTypeVector %[[#I64]] 334; CHECK-DAG: %[[#PTR:]] = OpTypePointer Input %[[#VEC]]35; CHECK-DAG: %[[#FN:]] = OpTypeFunction %[[#I64]] %[[#I32]]36; CHECK-DAG: %[[#GET_NUM_GROUPS]] = OpVariable %[[#PTR]] Input37; CHECK-DAG: %[[#ONE:]] = OpConstant %[[#I64]] 138; CHECK-DAG: %[[#THREE:]] = OpConstant %[[#I32]] 339 40;; Functions:41; CHECK: OpFunction %[[#I64]] None %[[#FN]]42; CHECK: %[[#DIM:]] = OpFunctionParameter %[[#I32]]43 44;; get_num_groups(0): OpLoad + OpCompositeExtract.45; CHECK: %[[#TMP1:]] = OpLoad %[[#VEC]] %[[#GET_NUM_GROUPS]]46; CHECK: %[[#X:]] = OpCompositeExtract %[[#I64]] %[[#TMP1]] 047 48;; get_num_groups(5): OpConstant of one.49; CHECK: OpIAdd %[[#I64]] %[[#X]] %[[#ONE]]50 51;; get_num_groups(dim): Implementation using OpSelect.52; CHECK-DAG: %[[#TMP2:]] = OpLoad %[[#VEC]] %[[#GET_NUM_GROUPS]]53; CHECK-DAG: %[[#TMP3:]] = OpVectorExtractDynamic %[[#I64]] %[[#TMP2]] %[[#DIM]]54; CHECK-DAG: %[[#COND:]] = OpULessThan %[[#BOOL]] %[[#DIM]] %[[#THREE]]55; CHECK: %[[#UNKNOWN:]] = OpSelect %[[#I64]] %[[#COND]] %[[#TMP3]] %[[#ONE]]56