xref: /llvm-project/llvm/test/CodeGen/DirectX/abs-vec.ll (revision d8e5c0b4e546c73b2d10956a9517f1f2727702ae)
1*d8e5c0b4SFarzon Lotfi; RUN: opt -S  -dxil-intrinsic-expansion  < %s | FileCheck %s
2*d8e5c0b4SFarzon Lotfi
3*d8e5c0b4SFarzon Lotfi; Make sure dxil operation function calls for abs are generated for int vectors.
4*d8e5c0b4SFarzon Lotfi
5*d8e5c0b4SFarzon Lotfi; CHECK-LABEL: abs_i16Vec2
6*d8e5c0b4SFarzon Lotfidefine noundef <2 x i16> @abs_i16Vec2(<2 x i16> noundef %a) #0 {
7*d8e5c0b4SFarzon Lotfientry:
8*d8e5c0b4SFarzon Lotfi; CHECK: sub <2 x i16> zeroinitializer, %a
9*d8e5c0b4SFarzon Lotfi; CHECK: call <2 x i16> @llvm.smax.v2i16(<2 x i16> %a, <2 x i16> %{{.*}})
10*d8e5c0b4SFarzon Lotfi  %elt.abs = call <2 x i16> @llvm.abs.v2i16(<2 x i16> %a, i1 false)
11*d8e5c0b4SFarzon Lotfi  ret <2 x i16> %elt.abs
12*d8e5c0b4SFarzon Lotfi}
13*d8e5c0b4SFarzon Lotfi
14*d8e5c0b4SFarzon Lotfi; CHECK-LABEL: abs_i32Vec3
15*d8e5c0b4SFarzon Lotfidefine noundef <3 x i32> @abs_i32Vec3(<3 x i32> noundef %a) #0 {
16*d8e5c0b4SFarzon Lotfientry:
17*d8e5c0b4SFarzon Lotfi; CHECK: sub <3 x i32> zeroinitializer, %a
18*d8e5c0b4SFarzon Lotfi; CHECK: call <3 x i32> @llvm.smax.v3i32(<3 x i32> %a, <3 x i32> %{{.*}})
19*d8e5c0b4SFarzon Lotfi  %elt.abs = call <3 x i32> @llvm.abs.v3i32(<3 x i32> %a, i1 false)
20*d8e5c0b4SFarzon Lotfi  ret <3 x i32> %elt.abs
21*d8e5c0b4SFarzon Lotfi}
22*d8e5c0b4SFarzon Lotfi
23*d8e5c0b4SFarzon Lotfi; CHECK-LABEL: abs_i64Vec4
24*d8e5c0b4SFarzon Lotfidefine noundef <4 x i64> @abs_i64Vec4(<4 x i64> noundef %a) #0 {
25*d8e5c0b4SFarzon Lotfientry:
26*d8e5c0b4SFarzon Lotfi; CHECK: sub <4 x i64> zeroinitializer, %a
27*d8e5c0b4SFarzon Lotfi; CHECK: call <4 x i64> @llvm.smax.v4i64(<4 x i64> %a, <4 x i64> %{{.*}})
28*d8e5c0b4SFarzon Lotfi  %elt.abs = call <4 x i64> @llvm.abs.v4i64(<4 x i64> %a, i1 false)
29*d8e5c0b4SFarzon Lotfi  ret <4 x i64> %elt.abs
30*d8e5c0b4SFarzon Lotfi}
31*d8e5c0b4SFarzon Lotfi
32*d8e5c0b4SFarzon Lotfideclare <2 x i16> @llvm.abs.v2i16(<2 x i16>, i1 immarg)
33*d8e5c0b4SFarzon Lotfideclare <3 x i32> @llvm.abs.v3i32(<3 x i32>, i1 immarg)
34*d8e5c0b4SFarzon Lotfideclare <4 x i64> @llvm.abs.v4i64(<4 x i64>, i1 immarg)
35