106 lines · plain
1; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s2; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}3 4; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s5; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}6 7; CHECK-DAG: %[[Char:.*]] = OpTypeInt 8 08; CHECK-DAG: %[[Void:.*]] = OpTypeVoid9; CHECK-DAG: %[[PtrChar:.*]] = OpTypePointer Function %[[Char]]10; CHECK-DAG: %[[StructChar:.*]] = OpTypeStruct %[[Char]] %[[Char]]11; CHECK-DAG: %[[NullChar:.*]] = OpConstantNull %[[Char]]12; CHECK-DAG: %[[Int:.*]] = OpTypeInt 32 013; CHECK-DAG: %[[PtrInt:.*]] = OpTypePointer Function %[[Int]]14; CHECK-DAG: %[[StructInt:.*]] = OpTypeStruct %[[Int]] %[[Int]]15; CHECK-DAG: %[[NullInt:.*]] = OpConstantNull %[[Int]]16; CHECK-DAG: %[[Bool:.*]] = OpTypeBool17; CHECK-DAG: %[[V2Bool:.*]] = OpTypeVector %[[Bool]] 218; CHECK-DAG: %[[Long:.*]] = OpTypeInt 64 019; CHECK-DAG: %[[V2Long:.*]] = OpTypeVector %[[Long]] 220; CHECK-DAG: %[[PtrV2Long:.*]] = OpTypePointer Function %[[V2Long]]21; CHECK-DAG: %[[StructV2Long:.*]] = OpTypeStruct %[[V2Long]] %[[V2Long]]22; CHECK-DAG: %[[ZeroV2Long:.*]] = OpConstantNull %[[V2Long]]23; CHECK-DAG: %[[StructLong:.*]] = OpTypeStruct %[[Long]] %[[Long]]24 25; CHECK: OpFunction26; CHECK: %[[A:.*]] = OpFunctionParameter %[[Char]]27; CHECK: %[[B:.*]] = OpFunctionParameter %[[Char]]28; CHECK: %[[Ptr:.*]] = OpFunctionParameter %[[PtrChar]]29; CHECK: %[[Struct:.*]] = OpIAddCarry %[[StructChar]] %[[A]] %[[B]]30; CHECK: %[[Val:.*]] = OpCompositeExtract %[[Char]] %[[Struct]] 031; CHECK: %[[Over:.*]] = OpCompositeExtract %[[Char]] %[[Struct]] 132; CHECK: %[[IsOver:.*]] = OpINotEqual %[[Bool]] %[[Over]] %[[NullChar]]33; CHECK: %[[Res:.*]] = OpSelect %[[Char]] %[[IsOver]] %[[NullChar]] %[[Val]]34; CHECK: OpStore %[[Ptr]] %[[Res]] Aligned 135; CHECK: OpReturn36define dso_local spir_func void @umulo_i8(i8 zeroext %a, i8 zeroext %b, ptr nocapture %c) local_unnamed_addr {37entry:38 %umul = tail call { i8, i1 } @llvm.uadd.with.overflow.i8(i8 %a, i8 %b)39 %cmp = extractvalue { i8, i1 } %umul, 140 %umul.value = extractvalue { i8, i1 } %umul, 041 %storemerge = select i1 %cmp, i8 0, i8 %umul.value42 store i8 %storemerge, ptr %c, align 143 ret void44}45 46; CHECK: OpFunction47; CHECK: %[[A2:.*]] = OpFunctionParameter %[[Int]]48; CHECK: %[[B2:.*]] = OpFunctionParameter %[[Int]]49; CHECK: %[[Ptr2:.*]] = OpFunctionParameter %[[PtrInt]]50; CHECK: %[[Struct2:.*]] = OpIAddCarry %[[StructInt]] %[[B2]] %[[A2]]51; CHECK: %[[Val2:.*]] = OpCompositeExtract %[[Int]] %[[Struct2]] 052; CHECK: %[[Over2:.*]] = OpCompositeExtract %[[Int]] %[[Struct2]] 153; CHECK: %[[IsOver2:.*]] = OpINotEqual %[[Bool]] %[[Over2]] %[[NullInt]]54; CHECK: %[[Res2:.*]] = OpSelect %[[Int]] %[[IsOver2]] %[[NullInt]] %[[Val2]]55; CHECK: OpStore %[[Ptr2]] %[[Res2]] Aligned 456; CHECK: OpReturn57define dso_local spir_func void @umulo_i32(i32 %a, i32 %b, ptr nocapture %c) local_unnamed_addr {58entry:59 %umul = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %b, i32 %a)60 %umul.val = extractvalue { i32, i1 } %umul, 061 %umul.ov = extractvalue { i32, i1 } %umul, 162 %spec.select = select i1 %umul.ov, i32 0, i32 %umul.val63 store i32 %spec.select, ptr %c, align 464 ret void65}66 67; CHECK: OpFunction68; CHECK: %[[A3:.*]] = OpFunctionParameter %[[V2Long]]69; CHECK: %[[B3:.*]] = OpFunctionParameter %[[V2Long]]70; CHECK: %[[Ptr3:.*]] = OpFunctionParameter %[[PtrV2Long]]71; CHECK: %[[Struct3:.*]] = OpIAddCarry %[[StructV2Long]] %[[A3]] %[[B3]]72; CHECK: %[[Val3:.*]] = OpCompositeExtract %[[V2Long]] %[[Struct3]] 073; CHECK: %[[Over3:.*]] = OpCompositeExtract %[[V2Long]] %[[Struct3]] 174; CHECK: %[[IsOver3:.*]] = OpINotEqual %[[V2Bool]] %[[Over3]] %[[ZeroV2Long]]75; CHECK: %[[Res3:.*]] = OpSelect %[[V2Long]] %[[IsOver3]] %[[ZeroV2Long]] %[[Val3]]76; CHECK: OpStore %[[Ptr3]] %[[Res3]] Aligned 1677; CHECK: OpReturn78define dso_local spir_func void @umulo_v2i64(<2 x i64> %a, <2 x i64> %b, ptr %p) nounwind {79 %umul = call {<2 x i64>, <2 x i1>} @llvm.uadd.with.overflow.v2i64(<2 x i64> %a, <2 x i64> %b)80 %umul.val = extractvalue {<2 x i64>, <2 x i1>} %umul, 081 %umul.ov = extractvalue {<2 x i64>, <2 x i1>} %umul, 182 %zero = alloca <2 x i64>, align 1683 %spec.select = select <2 x i1> %umul.ov, <2 x i64> <i64 0, i64 0>, <2 x i64> %umul.val84 store <2 x i64> %spec.select, ptr %p85 ret void86}87 88; This is to check that we re-use the same OpTypeStruct for two identical references to { i64, i1 }.89; CHECK: OpFunction90; CHECK: OpIAddCarry %[[StructLong]]91; CHECK: OpIAddCarry %[[StructLong]]92; CHECK: OpReturn93define i64 @foo(i64 %a, i64 %b) {94 %r1 = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)95 %r2 = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)96 %d1 = extractvalue { i64, i1 } %r1, 097 %d2 = extractvalue { i64, i1 } %r2, 098 %sum = add i64 %d1, %d299 ret i64 %sum100}101 102declare {i8, i1} @llvm.uadd.with.overflow.i8(i8, i8)103declare {i32, i1} @llvm.uadd.with.overflow.i32(i32, i32)104declare {i64, i1} @llvm.uadd.with.overflow.i64(i64, i64)105declare {<2 x i64>, <2 x i1>} @llvm.uadd.with.overflow.v2i64(<2 x i64>, <2 x i64>)106