| 1 |
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-vulkan-unknown %s -o - | FileCheck %s |
| 2 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-vulkan-unknown %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
; Test lowering to spir-v backend for various types and scalar/vector |
| 5 |
|
| 6 |
; CHECK-DAG: %[[#f16:]] = OpTypeFloat 16 |
| 7 |
; CHECK-DAG: %[[#f32:]] = OpTypeFloat 32 |
| 8 |
; CHECK-DAG: %[[#uint:]] = OpTypeInt 32 0 |
| 9 |
; CHECK-DAG: %[[#v4_half:]] = OpTypeVector %[[#f16]] 4 |
| 10 |
; CHECK-DAG: %[[#scope:]] = OpConstant %[[#uint]] 3 |
| 11 |
|
| 12 |
; CHECK-LABEL: Begin function test_float |
| 13 |
; CHECK: %[[#fexpr:]] = OpFunctionParameter %[[#f32]] |
| 14 |
define float @test_float(float %fexpr) { |
| 15 |
entry: |
| 16 |
; CHECK: %[[#fret:]] = OpGroupNonUniformFAdd %[[#f32]] %[[#scope]] Reduce %[[#fexpr]] |
| 17 |
%0 = call float @llvm.spv.wave.reduce.sum.f32(float %fexpr) |
| 18 |
ret float %0 |
| 19 |
} |
| 20 |
|
| 21 |
; CHECK-LABEL: Begin function test_int |
| 22 |
; CHECK: %[[#iexpr:]] = OpFunctionParameter %[[#uint]] |
| 23 |
define i32 @test_int(i32 %iexpr) { |
| 24 |
entry: |
| 25 |
; CHECK: %[[#iret:]] = OpGroupNonUniformIAdd %[[#uint]] %[[#scope]] Reduce %[[#iexpr]] |
| 26 |
%0 = call i32 @llvm.spv.wave.reduce.sum.i32(i32 %iexpr) |
| 27 |
ret i32 %0 |
| 28 |
} |
| 29 |
|
| 30 |
; CHECK-LABEL: Begin function test_vhalf |
| 31 |
; CHECK: %[[#vbexpr:]] = OpFunctionParameter %[[#v4_half]] |
| 32 |
define <4 x half> @test_vhalf(<4 x half> %vbexpr) { |
| 33 |
entry: |
| 34 |
; CHECK: %[[#vhalfret:]] = OpGroupNonUniformFAdd %[[#v4_half]] %[[#scope]] Reduce %[[#vbexpr]] |
| 35 |
%0 = call <4 x half> @llvm.spv.wave.reduce.sum.v4half(<4 x half> %vbexpr) |
| 36 |
ret <4 x half> %0 |
| 37 |
} |
| 38 |
|
| 39 |
declare float @llvm.spv.wave.reduce.sum.f32(float) |
| 40 |
declare i32 @llvm.spv.wave.reduce.sum.i32(i32) |
| 41 |
declare <4 x half> @llvm.spv.wave.reduce.sum.v4half(<4 x half>) |