| 1 |
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 2 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
; CHECK-SPIRV-DAG: %[[#int:]] = OpTypeInt 32 0 |
| 5 |
; CHECK-SPIRV-DAG: %[[#int2:]] = OpTypeVector %[[#int]] 2 |
| 6 |
; CHECK-SPIRV-DAG: %[[#float:]] = OpTypeFloat 32 |
| 7 |
; CHECK-SPIRV-DAG: %[[#float2:]] = OpTypeVector %[[#float]] 2 |
| 8 |
|
| 9 |
; CHECK-SPIRV: OpFunction |
| 10 |
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]] |
| 11 |
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]] |
| 12 |
; CHECK-SPIRV: %[[#]] = OpSDiv %[[#int2]] %[[#A]] %[[#B]] |
| 13 |
; CHECK-SPIRV: OpFunctionEnd |
| 14 |
|
| 15 |
;; kernel void testSDiv(int2 a, int2 b, global int2 *res) { |
| 16 |
;; res[0] = a / b; |
| 17 |
;; } |
| 18 |
|
| 19 |
define dso_local spir_kernel void @testSDiv(<2 x i32> noundef %a, <2 x i32> noundef %b, ptr addrspace(1) nocapture noundef writeonly %res) local_unnamed_addr { |
| 20 |
entry: |
| 21 |
%div = sdiv <2 x i32> %a, %b |
| 22 |
store <2 x i32> %div, ptr addrspace(1) %res, align 8 |
| 23 |
ret void |
| 24 |
} |
| 25 |
|
| 26 |
; CHECK-SPIRV: OpFunction |
| 27 |
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]] |
| 28 |
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]] |
| 29 |
; CHECK-SPIRV: %[[#]] = OpUDiv %[[#int2]] %[[#A]] %[[#B]] |
| 30 |
; CHECK-SPIRV: OpFunctionEnd |
| 31 |
|
| 32 |
;; kernel void testUDiv(uint2 a, uint2 b, global uint2 *res) { |
| 33 |
;; res[0] = a / b; |
| 34 |
;; } |
| 35 |
|
| 36 |
define dso_local spir_kernel void @testUDiv(<2 x i32> noundef %a, <2 x i32> noundef %b, ptr addrspace(1) nocapture noundef writeonly %res) local_unnamed_addr { |
| 37 |
entry: |
| 38 |
%div = udiv <2 x i32> %a, %b |
| 39 |
store <2 x i32> %div, ptr addrspace(1) %res, align 8 |
| 40 |
ret void |
| 41 |
} |
| 42 |
|
| 43 |
; CHECK-SPIRV: OpFunction |
| 44 |
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]] |
| 45 |
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]] |
| 46 |
; CHECK-SPIRV: %[[#]] = OpFDiv %[[#float2]] %[[#A]] %[[#B]] |
| 47 |
; CHECK-SPIRV: OpFunctionEnd |
| 48 |
|
| 49 |
;; kernel void testFDiv(float2 a, float2 b, global float2 *res) { |
| 50 |
;; res[0] = a / b; |
| 51 |
;; } |
| 52 |
|
| 53 |
define dso_local spir_kernel void @testFDiv(<2 x float> noundef %a, <2 x float> noundef %b, ptr addrspace(1) nocapture noundef writeonly %res) local_unnamed_addr { |
| 54 |
entry: |
| 55 |
%div = fdiv <2 x float> %a, %b |
| 56 |
store <2 x float> %div, ptr addrspace(1) %res, align 8 |
| 57 |
ret void |
| 58 |
} |
| 59 |
|
| 60 |
; CHECK-SPIRV: OpFunction |
| 61 |
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]] |
| 62 |
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]] |
| 63 |
; CHECK-SPIRV: %[[#]] = OpSRem %[[#int2]] %[[#A]] %[[#B]] |
| 64 |
; CHECK-SPIRV: OpFunctionEnd |
| 65 |
|
| 66 |
;; kernel void testSRem(int2 a, int2 b, global int2 *res) { |
| 67 |
;; res[0] = a % b; |
| 68 |
;; } |
| 69 |
|
| 70 |
define dso_local spir_kernel void @testSRem(<2 x i32> noundef %a, <2 x i32> noundef %b, ptr addrspace(1) nocapture noundef writeonly %res) local_unnamed_addr { |
| 71 |
entry: |
| 72 |
%rem = srem <2 x i32> %a, %b |
| 73 |
store <2 x i32> %rem, ptr addrspace(1) %res, align 8 |
| 74 |
ret void |
| 75 |
} |
| 76 |
|
| 77 |
; CHECK-SPIRV: OpFunction |
| 78 |
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]] |
| 79 |
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]] |
| 80 |
; CHECK-SPIRV: %[[#]] = OpUMod %[[#int2]] %[[#A]] %[[#B]] |
| 81 |
; CHECK-SPIRV: OpFunctionEnd |
| 82 |
|
| 83 |
;; kernel void testUMod(uint2 a, uint2 b, global uint2 *res) { |
| 84 |
;; res[0] = a % b; |
| 85 |
;; } |
| 86 |
|
| 87 |
define dso_local spir_kernel void @testUMod(<2 x i32> noundef %a, <2 x i32> noundef %b, ptr addrspace(1) nocapture noundef writeonly %res) local_unnamed_addr { |
| 88 |
entry: |
| 89 |
%rem = urem <2 x i32> %a, %b |
| 90 |
store <2 x i32> %rem, ptr addrspace(1) %res, align 8 |
| 91 |
ret void |
| 92 |
} |