| 1 |
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s |
| 2 |
; 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 %s |
| 5 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 6 |
|
| 7 |
; CHECK-DAG: %[[Char:.*]] = OpTypeInt 8 0 |
| 8 |
; CHECK-DAG: %[[Void:.*]] = OpTypeVoid |
| 9 |
; 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 0 |
| 13 |
; CHECK-DAG: %[[PtrInt:.*]] = OpTypePointer Function %[[Int]] |
| 14 |
; CHECK-DAG: %[[StructInt:.*]] = OpTypeStruct %[[Int]] %[[Int]] |
| 15 |
; CHECK-DAG: %[[NullInt:.*]] = OpConstantNull %[[Int]] |
| 16 |
; CHECK-DAG: %[[Bool:.*]] = OpTypeBool |
| 17 |
; CHECK-DAG: %[[V2Bool:.*]] = OpTypeVector %[[Bool]] 2 |
| 18 |
; CHECK-DAG: %[[Long:.*]] = OpTypeInt 64 0 |
| 19 |
; CHECK-DAG: %[[V2Long:.*]] = OpTypeVector %[[Long]] 2 |
| 20 |
; CHECK-DAG: %[[PtrV2Long:.*]] = OpTypePointer Function %[[V2Long]] |
| 21 |
; CHECK-DAG: %[[StructV2Long:.*]] = OpTypeStruct %[[V2Long]] %[[V2Long]] |
| 22 |
; CHECK-DAG: %[[ZeroV2Long:.*]] = OpConstantNull %[[V2Long]] |
| 23 |
|
| 24 |
; CHECK: OpFunction |
| 25 |
; CHECK: %[[A:.*]] = OpFunctionParameter %[[Char]] |
| 26 |
; CHECK: %[[B:.*]] = OpFunctionParameter %[[Char]] |
| 27 |
; CHECK: %[[Ptr:.*]] = OpFunctionParameter %[[PtrChar]] |
| 28 |
; CHECK: %[[Struct:.*]] = OpISubBorrow %[[StructChar]] %[[A]] %[[B]] |
| 29 |
; CHECK: %[[Val:.*]] = OpCompositeExtract %[[Char]] %[[Struct]] 0 |
| 30 |
; CHECK: %[[Over:.*]] = OpCompositeExtract %[[Char]] %[[Struct]] 1 |
| 31 |
; CHECK: %[[IsOver:.*]] = OpINotEqual %[[Bool]] %[[Over]] %[[NullChar]] |
| 32 |
; CHECK: %[[Res:.*]] = OpSelect %[[Char]] %[[IsOver]] %[[NullChar]] %[[Val]] |
| 33 |
; CHECK: OpStore %[[Ptr]] %[[Res]] Aligned 1 |
| 34 |
; CHECK: OpReturn |
| 35 |
define dso_local spir_func void @umulo_i8(i8 zeroext %a, i8 zeroext %b, ptr nocapture %c) local_unnamed_addr { |
| 36 |
entry: |
| 37 |
%umul = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %a, i8 %b) |
| 38 |
%cmp = extractvalue { i8, i1 } %umul, 1 |
| 39 |
%umul.value = extractvalue { i8, i1 } %umul, 0 |
| 40 |
%storemerge = select i1 %cmp, i8 0, i8 %umul.value |
| 41 |
store i8 %storemerge, ptr %c, align 1 |
| 42 |
ret void |
| 43 |
} |
| 44 |
|
| 45 |
; CHECK: OpFunction |
| 46 |
; CHECK: %[[A2:.*]] = OpFunctionParameter %[[Int]] |
| 47 |
; CHECK: %[[B2:.*]] = OpFunctionParameter %[[Int]] |
| 48 |
; CHECK: %[[Ptr2:.*]] = OpFunctionParameter %[[PtrInt]] |
| 49 |
; CHECK: %[[Struct2:.*]] = OpISubBorrow %[[StructInt]] %[[B2]] %[[A2]] |
| 50 |
; CHECK: %[[Val2:.*]] = OpCompositeExtract %[[Int]] %[[Struct2]] 0 |
| 51 |
; CHECK: %[[Over2:.*]] = OpCompositeExtract %[[Int]] %[[Struct2]] 1 |
| 52 |
; CHECK: %[[IsOver2:.*]] = OpINotEqual %[[Bool]] %[[Over2]] %[[NullInt]] |
| 53 |
; CHECK: %[[Res2:.*]] = OpSelect %[[Int]] %[[IsOver2]] %[[NullInt]] %[[Val2]] |
| 54 |
; CHECK: OpStore %[[Ptr2]] %[[Res2]] Aligned 4 |
| 55 |
; CHECK: OpReturn |
| 56 |
define dso_local spir_func void @umulo_i32(i32 %a, i32 %b, ptr nocapture %c) local_unnamed_addr { |
| 57 |
entry: |
| 58 |
%umul = tail call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %b, i32 %a) |
| 59 |
%umul.val = extractvalue { i32, i1 } %umul, 0 |
| 60 |
%umul.ov = extractvalue { i32, i1 } %umul, 1 |
| 61 |
%spec.select = select i1 %umul.ov, i32 0, i32 %umul.val |
| 62 |
store i32 %spec.select, ptr %c, align 4 |
| 63 |
ret void |
| 64 |
} |
| 65 |
|
| 66 |
; CHECK: OpFunction |
| 67 |
; CHECK: %[[A3:.*]] = OpFunctionParameter %[[V2Long]] |
| 68 |
; CHECK: %[[B3:.*]] = OpFunctionParameter %[[V2Long]] |
| 69 |
; CHECK: %[[Ptr3:.*]] = OpFunctionParameter %[[PtrV2Long]] |
| 70 |
; CHECK: %[[Struct3:.*]] = OpISubBorrow %[[StructV2Long]] %[[A3]] %[[B3]] |
| 71 |
; CHECK: %[[Val3:.*]] = OpCompositeExtract %[[V2Long]] %[[Struct3]] 0 |
| 72 |
; CHECK: %[[Over3:.*]] = OpCompositeExtract %[[V2Long]] %[[Struct3]] 1 |
| 73 |
; CHECK: %[[IsOver3:.*]] = OpINotEqual %[[V2Bool]] %[[Over3]] %[[ZeroV2Long]] |
| 74 |
; CHECK: %[[Res3:.*]] = OpSelect %[[V2Long]] %[[IsOver3]] %[[ZeroV2Long]] %[[Val3]] |
| 75 |
; CHECK: OpStore %[[Ptr3]] %[[Res3]] Aligned 16 |
| 76 |
; CHECK: OpReturn |
| 77 |
define dso_local spir_func void @umulo_v2i64(<2 x i64> %a, <2 x i64> %b, ptr %p) nounwind { |
| 78 |
%umul = call {<2 x i64>, <2 x i1>} @llvm.usub.with.overflow.v2i64(<2 x i64> %a, <2 x i64> %b) |
| 79 |
%umul.val = extractvalue {<2 x i64>, <2 x i1>} %umul, 0 |
| 80 |
%umul.ov = extractvalue {<2 x i64>, <2 x i1>} %umul, 1 |
| 81 |
%zero = alloca <2 x i64>, align 16 |
| 82 |
%spec.select = select <2 x i1> %umul.ov, <2 x i64> <i64 0, i64 0>, <2 x i64> %umul.val |
| 83 |
store <2 x i64> %spec.select, ptr %p |
| 84 |
ret void |
| 85 |
} |
| 86 |
|
| 87 |
declare {i8, i1} @llvm.usub.with.overflow.i8(i8, i8) |
| 88 |
declare {i32, i1} @llvm.usub.with.overflow.i32(i32, i32) |
| 89 |
declare {<2 x i64>, <2 x i1>} @llvm.usub.with.overflow.v2i64(<2 x i64>, <2 x i64>) |