| 1 |
; This test ensures that LLVM IR bitwise instructions result in logical SPIR-V instructions |
| 2 |
; when applied to i1 type |
| 3 |
|
| 4 |
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s |
| 5 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 6 |
|
| 7 |
; CHECK-DAG: %[[#Char:]] = OpTypeInt 8 0 |
| 8 |
; CHECK-DAG: %[[#Vec2Char:]] = OpTypeVector %[[#Char]] 2 |
| 9 |
; CHECK-DAG: %[[#Bool:]] = OpTypeBool |
| 10 |
; CHECK-DAG: %[[#Vec2Bool:]] = OpTypeVector %[[#Bool]] 2 |
| 11 |
|
| 12 |
; CHECK: OpBitwiseAnd %[[#Char]] |
| 13 |
; CHECK: OpBitwiseOr %[[#Char]] |
| 14 |
; CHECK: OpBitwiseXor %[[#Char]] |
| 15 |
; CHECK: OpBitwiseAnd %[[#Vec2Char]] |
| 16 |
; CHECK: OpBitwiseOr %[[#Vec2Char]] |
| 17 |
; CHECK: OpBitwiseXor %[[#Vec2Char]] |
| 18 |
|
| 19 |
; CHECK: OpLogicalAnd %[[#Bool]] |
| 20 |
|
| 21 |
; CHECK: OpLogicalAnd %[[#Bool]] |
| 22 |
; CHECK: OpLogicalOr %[[#Bool]] |
| 23 |
; CHECK: OpLogicalNotEqual %[[#Bool]] |
| 24 |
; CHECK: OpLogicalAnd %[[#Vec2Bool]] |
| 25 |
; CHECK: OpLogicalOr %[[#Vec2Bool]] |
| 26 |
; CHECK: OpLogicalNotEqual %[[#Vec2Bool]] |
| 27 |
|
| 28 |
define void @test1(i8 noundef %arg1, i8 noundef %arg2, ptr addrspace(1) %out) { |
| 29 |
%cond1 = and i8 %arg1, %arg2 |
| 30 |
store volatile i8 %cond1, ptr addrspace(1) %out |
| 31 |
%cond2 = or i8 %arg1, %arg2 |
| 32 |
store volatile i8 %cond2, ptr addrspace(1) %out |
| 33 |
%cond3 = xor i8 %arg1, %arg2 |
| 34 |
store volatile i8 %cond3, ptr addrspace(1) %out |
| 35 |
ret void |
| 36 |
} |
| 37 |
|
| 38 |
define void @test1v(<2 x i8> noundef %arg1, <2 x i8> noundef %arg2, ptr addrspace(1) %out) { |
| 39 |
%cond1 = and <2 x i8> %arg1, %arg2 |
| 40 |
store volatile <2 x i8> %cond1, ptr addrspace(1) %out |
| 41 |
%cond2 = or <2 x i8> %arg1, %arg2 |
| 42 |
store volatile <2 x i8> %cond2, ptr addrspace(1) %out |
| 43 |
%cond3 = xor <2 x i8> %arg1, %arg2 |
| 44 |
store volatile <2 x i8> %cond3, ptr addrspace(1) %out |
| 45 |
ret void |
| 46 |
} |
| 47 |
|
| 48 |
define void @test2(float noundef %real, float noundef %imag) { |
| 49 |
entry: |
| 50 |
%realabs = tail call spir_func noundef float @_Z16__spirv_ocl_fabsf(float noundef %real) |
| 51 |
%cond1 = fcmp oeq float %realabs, 1.000000e+00 |
| 52 |
%cond2 = fcmp oeq float %imag, 0.000000e+00 |
| 53 |
%cond3 = and i1 %cond1, %cond2 |
| 54 |
br i1 %cond3, label %midlbl, label %cleanup |
| 55 |
midlbl: |
| 56 |
br label %cleanup |
| 57 |
cleanup: |
| 58 |
ret void |
| 59 |
} |
| 60 |
|
| 61 |
define void @test3(i1 noundef %arg1, i1 noundef %arg2, ptr addrspace(1) %out) { |
| 62 |
%cond1 = and i1 %arg1, %arg2 |
| 63 |
store volatile i1 %cond1, ptr addrspace(1) %out |
| 64 |
%cond2 = or i1 %arg1, %arg2 |
| 65 |
store volatile i1 %cond2, ptr addrspace(1) %out |
| 66 |
%cond3 = xor i1 %arg1, %arg2 |
| 67 |
store volatile i1 %cond3, ptr addrspace(1) %out |
| 68 |
ret void |
| 69 |
} |
| 70 |
|
| 71 |
define void @test3v(<2 x i1> noundef %arg1, <2 x i1> noundef %arg2, ptr addrspace(1) %out) { |
| 72 |
%cond1 = and <2 x i1> %arg1, %arg2 |
| 73 |
store volatile <2 x i1> %cond1, ptr addrspace(1) %out |
| 74 |
%cond2 = or <2 x i1> %arg1, %arg2 |
| 75 |
store volatile <2 x i1> %cond2, ptr addrspace(1) %out |
| 76 |
%cond3 = xor <2 x i1> %arg1, %arg2 |
| 77 |
store volatile <2 x i1> %cond3, ptr addrspace(1) %out |
| 78 |
ret void |
| 79 |
} |
| 80 |
|
| 81 |
declare dso_local spir_func noundef float @_Z16__spirv_ocl_fabsf(float noundef) |