xref: /llvm-project/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/abs.ll (revision cf3d6fded9eaf1372ccfde1d49dd91df6762d98c)
1; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s
2; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3
4; CHECK: OpExtInstImport "GLSL.std.450"
5
6define void @main() #1 {
7entry:
8  %i = alloca i32, align 4
9  %absi = alloca i32, align 4
10  %f = alloca float, align 4
11  %absf = alloca float, align 4
12  %0 = load i32, ptr %i, align 4
13
14; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] SAbs %[[#]]
15  %elt.abs = call i32 @llvm.abs.i32(i32 %0, i1 false)
16
17  store i32 %elt.abs, ptr %absi, align 4
18  %1 = load float, ptr %f, align 4
19
20; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FAbs %[[#]]
21  %elt.abs1 = call float @llvm.fabs.f32(float %1)
22
23  store float %elt.abs1, ptr %absf, align 4
24  ret void
25}
26
27declare i32 @llvm.abs.i32(i32, i1 immarg) #2
28declare float @llvm.fabs.f32(float) #2
29