diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/abs.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/abs.ll index 7031129de21ac..38c033bdd4dd7 100644 --- a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/abs.ll +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/abs.ll @@ -1,4 +1,5 @@ -; RUN: llc -O0 -mtriple=spirv-unknown-linux %s -o - | FileCheck %s +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} ; CHECK: OpExtInstImport "GLSL.std.450" diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/ceil.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/ceil.ll new file mode 100644 index 0000000000000..1b358ae54502b --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/ceil.ll @@ -0,0 +1,20 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef float @ceil_float(float noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Ceil %[[#]] + %elt.ceil = call float @llvm.ceil.f32(float %a) + ret float %elt.ceil +} + +define noundef half @ceil_half(half noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Ceil %[[#]] + %elt.ceil = call half @llvm.ceil.f16(half %a) + ret half %elt.ceil +} + +declare half @llvm.ceil.f16(half) +declare float @llvm.ceil.f32(float) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/cos.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/cos.ll new file mode 100644 index 0000000000000..28675cf9f1541 --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/cos.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef float @cos_float(float noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Cos %[[#]] + %elt.cos = call float @llvm.cos.f32(float %a) + ret float %elt.cos +} + +define noundef half @cos_half(half noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Cos %[[#]] + %elt.cos = call half @llvm.cos.f16(half %a) + ret half %elt.cos +} + +declare half @llvm.cos.f16(half) +declare float @llvm.cos.f32(float) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/exp.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/exp.ll new file mode 100644 index 0000000000000..ee230df41a6c7 --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/exp.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef float @exp_float(float noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Exp %[[#]] + %elt.exp = call float @llvm.exp.f32(float %a) + ret float %elt.exp +} + +define noundef half @exp_half(half noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Exp %[[#]] + %elt.exp = call half @llvm.exp.f16(half %a) + ret half %elt.exp +} + +declare half @llvm.exp.f16(half) +declare float @llvm.exp.f32(float) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/exp2.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/exp2.ll new file mode 100644 index 0000000000000..eeaca1b6560af --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/exp2.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef float @exp2_float(float noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Exp2 %[[#]] + %elt.exp2 = call float @llvm.exp2.f32(float %a) + ret float %elt.exp2 +} + +define noundef half @exp2_half(half noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Exp2 %[[#]] + %elt.exp2 = call half @llvm.exp2.f16(half %a) + ret half %elt.exp2 +} + +declare half @llvm.exp2.f16(half) +declare float @llvm.exp2.f32(float) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/floor.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/floor.ll new file mode 100644 index 0000000000000..5b972104d5038 --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/floor.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef float @floor_float(float noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Floor %[[#]] + %elt.floor = call float @llvm.floor.f32(float %a) + ret float %elt.floor +} + +define noundef half @floor_half(half noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Floor %[[#]] + %elt.floor = call half @llvm.floor.f16(half %a) + ret half %elt.floor +} + +declare half @llvm.floor.f16(half) +declare float @llvm.floor.f32(float) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fmad.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fmad.ll new file mode 100644 index 0000000000000..a3fec10a9e4bc --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fmad.ll @@ -0,0 +1,29 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef half @fmad_half(half noundef %a, half noundef %b, half noundef %c) #0 { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Fma %[[#]] %[[#]] %[[#]] + %dx.fmad = call half @llvm.fmuladd.f16(half %a, half %b, half %c) + ret half %dx.fmad +} + +define noundef float @fmad_float(float noundef %a, float noundef %b, float noundef %c) #0 { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Fma %[[#]] %[[#]] %[[#]] + %dx.fmad = call float @llvm.fmuladd.f32(float %a, float %b, float %c) + ret float %dx.fmad +} + +define noundef double @fmad_double(double noundef %a, double noundef %b, double noundef %c) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Fma %[[#]] %[[#]] %[[#]] + %dx.fmad = call double @llvm.fmuladd.f64(double %a, double %b, double %c) + ret double %dx.fmad +} + +declare half @llvm.fmuladd.f16(half, half, half) +declare float @llvm.fmuladd.f32(float, float, float) +declare double @llvm.fmuladd.f64(double, double, double) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fmax.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fmax.ll new file mode 100644 index 0000000000000..48e916581f9ff --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fmax.ll @@ -0,0 +1,29 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} +; TODO: This need to be NMax: See https://github.com/llvm/llvm-project/issues/87072 +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef half @test_fmax_half(half noundef %a, half noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FMax %[[#]] %[[#]] + %0 = call half @llvm.maxnum.f16(half %a, half %b) + ret half %0 +} + +define noundef float @test_fmax_float(float noundef %a, float noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FMax %[[#]] %[[#]] + %0 = call float @llvm.maxnum.f32(float %a, float %b) + ret float %0 +} + +define noundef double @test_fmax_double(double noundef %a, double noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FMax %[[#]] %[[#]] + %0 = call double @llvm.maxnum.f64(double %a, double %b) + ret double %0 +} + +declare half @llvm.maxnum.f16(half, half) +declare float @llvm.maxnum.f32(float, float) +declare double @llvm.maxnum.f64(double, double) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fmin.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fmin.ll new file mode 100644 index 0000000000000..5bfd69c972a3f --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fmin.ll @@ -0,0 +1,31 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} +; TODO: This need to be NMin: See https://github.com/llvm/llvm-project/issues/87072 + +; CHECK: OpExtInstImport "GLSL.std.450" +; CHECK: OpMemoryModel Logical GLSL450 + +define noundef half @test_fmax_half(half noundef %a, half noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FMin %[[#]] %[[#]] + %0 = call half @llvm.minnum.f16(half %a, half %b) + ret half %0 +} + +define noundef float @test_fmax_float(float noundef %a, float noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FMin %[[#]] %[[#]] + %0 = call float @llvm.minnum.f32(float %a, float %b) + ret float %0 +} + +define noundef double @test_fmax_double(double noundef %a, double noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FMin %[[#]] %[[#]] + %0 = call double @llvm.minnum.f64(double %a, double %b) + ret double %0 +} + +declare half @llvm.minnum.f16(half, half) +declare float @llvm.minnum.f32(float, float) +declare double @llvm.minnum.f64(double, double) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/log.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/log.ll new file mode 100644 index 0000000000000..5a09f32b83b2d --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/log.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef float @log_float(float noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Log %[[#]] + %elt.log = call float @llvm.log.f32(float %a) + ret float %elt.log +} + +define noundef half @log_half(half noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Log %[[#]] + %elt.log = call half @llvm.log.f16(half %a) + ret half %elt.log +} + +declare half @llvm.log.f16(half) +declare float @llvm.log.f32(float) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/log10.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/log10.ll index e7b00eb962f44..52ca6812d5d63 100644 --- a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/log10.ll +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/log10.ll @@ -1,4 +1,5 @@ -; RUN: llc -O0 -mtriple=spirv-unknown-linux %s -o - | FileCheck %s +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} ; CHECK: %[[#extinst:]] = OpExtInstImport "GLSL.std.450" diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/log2.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/log2.ll new file mode 100644 index 0000000000000..21f02a40fc089 --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/log2.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef float @log2_float(float noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Log2 %[[#]] + %elt.log2 = call float @llvm.log2.f32(float %a) + ret float %elt.log2 +} + +define noundef half @log2_half(half noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Log2 %[[#]] + %elt.log2 = call half @llvm.log2.f16(half %a) + ret half %elt.log2 +} + +declare half @llvm.log2.f16(half) +declare float @llvm.log2.f32(float) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/pow.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/pow.ll new file mode 100644 index 0000000000000..7fae9637946fa --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/pow.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef float @pow_float(float noundef %a,float noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Pow %[[#]] + %elt.pow = call float @llvm.pow.f32(float %a,float %b) + ret float %elt.pow +} + +define noundef half @pow_half(half noundef %a, half noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Pow %[[#]] + %elt.pow = call half @llvm.pow.f16(half %a, half %b) + ret half %elt.pow +} + +declare half @llvm.pow.f16(half,half) +declare float @llvm.pow.f32(float,float) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/reversebits.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/reversebits.ll new file mode 100644 index 0000000000000..e58c9ab6dfb1c --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/reversebits.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpMemoryModel Logical GLSL450 + +define noundef i32 @reversebits_i32(i32 noundef %a) { +entry: +; CHECK: %[[#]] = OpBitReverse %[[#]] %[[#]] + %elt.bitreverse = call i32 @llvm.bitreverse.i32(i32 %a) + ret i32 %elt.bitreverse +} + +define noundef i16 @reversebits_i16(i16 noundef %a) { +entry: +; CHECK: %[[#]] = OpBitReverse %[[#]] %[[#]] + %elt.bitreverse = call i16 @llvm.bitreverse.i16(i16 %a) + ret i16 %elt.bitreverse +} + +declare i16 @llvm.bitreverse.i16(i16) +declare i32 @llvm.bitreverse.i32(i32) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/round.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/round.ll new file mode 100644 index 0000000000000..baf20833840b6 --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/round.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef float @round_float(float noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] RoundEven %[[#]] + %elt.roundeven = call float @llvm.roundeven.f32(float %a) + ret float %elt.roundeven +} + +define noundef half @round_half(half noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] RoundEven %[[#]] + %elt.roundeven = call half @llvm.roundeven.f16(half %a) + ret half %elt.roundeven +} + +declare half @llvm.roundeven.f16(half) +declare float @llvm.roundeven.f32(float) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/sin.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/sin.ll new file mode 100644 index 0000000000000..061af5b37345a --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/sin.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef float @sin_float(float noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Sin %[[#]] + %elt.sin = call float @llvm.sin.f32(float %a) + ret float %elt.sin +} + +define noundef half @sin_half(half noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Sin %[[#]] + %elt.sin = call half @llvm.sin.f16(half %a) + ret half %elt.sin +} + +declare half @llvm.sin.f16(half) +declare float @llvm.sin.f32(float) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smax.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smax.ll new file mode 100644 index 0000000000000..6bbf10323faba --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smax.ll @@ -0,0 +1,29 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef i16 @test_smax_i16(i16 noundef %a, i16 noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] SMax %[[#]] %[[#]] + %0 = call i16 @llvm.smax.i16(i16 %a, i16 %b) + ret i16 %0 +} + +define noundef i32 @test_smax_i32(i32 noundef %a, i32 noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] SMax %[[#]] %[[#]] + %0 = call i32 @llvm.smax.i32(i32 %a, i32 %b) + ret i32 %0 +} + +define noundef i64 @test_smax_i64(i64 noundef %a, i64 noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] SMax %[[#]] %[[#]] + %0 = call i64 @llvm.smax.i64(i64 %a, i64 %b) + ret i64 %0 +} + +declare i16 @llvm.smax.i16(i16, i16) +declare i32 @llvm.smax.i32(i32, i32) +declare i64 @llvm.smax.i64(i64, i64) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smin.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smin.ll new file mode 100644 index 0000000000000..04ab9600c85b7 --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smin.ll @@ -0,0 +1,32 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + + +define noundef i16 @test_smin_i16(i16 noundef %a, i16 noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] SMin %[[#]] %[[#]] + %0 = call i16 @llvm.smin.i16(i16 %a, i16 %b) + ret i16 %0 +} + + +define noundef i32 @test_smin_i32(i32 noundef %a, i32 noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] SMin %[[#]] %[[#]] + %0 = call i32 @llvm.smin.i32(i32 %a, i32 %b) + ret i32 %0 +} + + +define noundef i64 @test_smin_i64(i64 noundef %a, i64 noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] SMin %[[#]] %[[#]] + %0 = call i64 @llvm.smin.i64(i64 %a, i64 %b) + ret i64 %0 +} + +declare i16 @llvm.smin.i16(i16, i16) +declare i32 @llvm.smin.i32(i32, i32) +declare i64 @llvm.smin.i64(i64, i64) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/sqrt.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/sqrt.ll new file mode 100644 index 0000000000000..6882b77a42733 --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/sqrt.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef float @sqrt_float(float noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Sqrt %[[#]] + %elt.sqrt = call float @llvm.sqrt.f32(float %a) + ret float %elt.sqrt +} + +define noundef half @sqrt_half(half noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Sqrt %[[#]] + %elt.sqrt = call half @llvm.sqrt.f16(half %a) + ret half %elt.sqrt +} + +declare half @llvm.sqrt.f16(half) +declare float @llvm.sqrt.f32(float) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/trunc.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/trunc.ll new file mode 100644 index 0000000000000..d75b7fa5a381d --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/trunc.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef float @trunc_float(float noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Trunc %[[#]] + %elt.trunc = call float @llvm.trunc.f32(float %a) + ret float %elt.trunc +} + +define noundef half @trunc_half(half noundef %a) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] Trunc %[[#]] + %elt.trunc = call half @llvm.trunc.f16(half %a) + ret half %elt.trunc +} + +declare half @llvm.trunc.f16(half) +declare float @llvm.trunc.f32(float) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/umax.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/umax.ll new file mode 100644 index 0000000000000..32677df3d5183 --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/umax.ll @@ -0,0 +1,29 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + +define noundef i16 @test_umax_i16(i16 noundef %a, i16 noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] UMax %[[#]] %[[#]] + %0 = call i16 @llvm.umax.i16(i16 %a, i16 %b) + ret i16 %0 +} + +define noundef i32 @test_umax_i32(i32 noundef %a, i32 noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] UMax %[[#]] %[[#]] + %0 = call i32 @llvm.umax.i32(i32 %a, i32 %b) + ret i32 %0 +} + +define noundef i64 @test_umax_i64(i64 noundef %a, i64 noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] UMax %[[#]] %[[#]] + %0 = call i64 @llvm.umax.i64(i64 %a, i64 %b) + ret i64 %0 +} + +declare i16 @llvm.umax.i16(i16, i16) +declare i32 @llvm.umax.i32(i32, i32) +declare i64 @llvm.umax.i64(i64, i64) diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/umin.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/umin.ll new file mode 100644 index 0000000000000..a91fb8096c2f0 --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/umin.ll @@ -0,0 +1,32 @@ +; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpExtInstImport "GLSL.std.450" + + +define noundef i16 @test_umin_i16(i16 noundef %a, i16 noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] UMin %[[#]] %[[#]] + %0 = call i16 @llvm.umin.i16(i16 %a, i16 %b) + ret i16 %0 +} + + +define noundef i32 @test_umin_i32(i32 noundef %a, i32 noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] UMin %[[#]] %[[#]] + %0 = call i32 @llvm.umin.i32(i32 %a, i32 %b) + ret i32 %0 +} + + +define noundef i64 @test_umin_i64(i64 noundef %a, i64 noundef %b) { +entry: +; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] UMin %[[#]] %[[#]] + %0 = call i64 @llvm.umin.i64(i64 %a, i64 %b) + ret i64 %0 +} + +declare i16 @llvm.umin.i16(i16, i16) +declare i32 @llvm.umin.i32(i32, i32) +declare i64 @llvm.umin.i64(i64, i64)