| 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: OpCapability GroupNonUniformArithmetic |
| 7 |
|
| 8 |
; CHECK-DAG: %[[#f16:]] = OpTypeFloat 16 |
| 9 |
; CHECK-DAG: %[[#f32:]] = OpTypeFloat 32 |
| 10 |
; CHECK-DAG: %[[#uint:]] = OpTypeInt 32 0 |
| 11 |
; CHECK-DAG: %[[#v4_half:]] = OpTypeVector %[[#f16]] 4 |
| 12 |
; CHECK-DAG: %[[#scope:]] = OpConstant %[[#uint]] 3 |
| 13 |
|
| 14 |
; CHECK-LABEL: Begin function test_float |
| 15 |
; CHECK: %[[#fexpr:]] = OpFunctionParameter %[[#f32]] |
| 16 |
define float @test_float(float %fexpr) { |
| 17 |
entry: |
| 18 |
; CHECK: %[[#fret:]] = OpGroupNonUniformFMax %[[#f32]] %[[#scope]] Reduce %[[#fexpr]] |
| 19 |
%0 = call float @llvm.spv.wave.reduce.max.f32(float %fexpr) |
| 20 |
ret float %0 |
| 21 |
} |
| 22 |
|
| 23 |
; CHECK-LABEL: Begin function test_int_signed |
| 24 |
; CHECK: %[[#iexpr:]] = OpFunctionParameter %[[#uint]] |
| 25 |
define i32 @test_int_signed(i32 %iexpr) { |
| 26 |
entry: |
| 27 |
; CHECK: %[[#iret:]] = OpGroupNonUniformSMax %[[#uint]] %[[#scope]] Reduce %[[#iexpr]] |
| 28 |
%0 = call i32 @llvm.spv.wave.reduce.max.i32(i32 %iexpr) |
| 29 |
ret i32 %0 |
| 30 |
} |
| 31 |
|
| 32 |
; CHECK-LABEL: Begin function test_int_unsigned |
| 33 |
; CHECK: %[[#iexpr:]] = OpFunctionParameter %[[#uint]] |
| 34 |
define i32 @test_int_unsigned(i32 %iexpr) { |
| 35 |
entry: |
| 36 |
; CHECK: %[[#iret:]] = OpGroupNonUniformUMax %[[#uint]] %[[#scope]] Reduce %[[#iexpr]] |
| 37 |
%0 = call i32 @llvm.spv.wave.reduce.umax.i32(i32 %iexpr) |
| 38 |
ret i32 %0 |
| 39 |
} |
| 40 |
|
| 41 |
; CHECK-LABEL: Begin function test_vhalf |
| 42 |
; CHECK: %[[#vbexpr:]] = OpFunctionParameter %[[#v4_half]] |
| 43 |
define <4 x half> @test_vhalf(<4 x half> %vbexpr) { |
| 44 |
entry: |
| 45 |
; CHECK: %[[#vhalfret:]] = OpGroupNonUniformFMax %[[#v4_half]] %[[#scope]] Reduce %[[#vbexpr]] |
| 46 |
%0 = call <4 x half> @llvm.spv.wave.reduce.max.v4half(<4 x half> %vbexpr) |
| 47 |
ret <4 x half> %0 |
| 48 |
} |
| 49 |
|
| 50 |
declare float @llvm.spv.wave.reduce.max.f32(float) |
| 51 |
declare i32 @llvm.spv.wave.reduce.max.i32(i32) |
| 52 |
declare <4 x half> @llvm.spv.wave.reduce.max.v4half(<4 x half>) |
| 53 |
|
| 54 |
declare float @llvm.spv.wave.reduce.umax.f32(float) |
| 55 |
declare i32 @llvm.spv.wave.reduce.umax.i32(i32) |
| 56 |
declare <4 x half> @llvm.spv.wave.reduce.umax.v4half(<4 x half>) |
| 57 |
|