1 ; RUN: opt -S -dxil-intrinsic-expansion < %s | FileCheck %s
\r
3 ; Make sure dxil operation function calls for cross are generated for half/float.
\r
5 declare <3 x half> @llvm.dx.cross.v3f16(<3 x half>, <3 x half>)
\r
6 declare <3 x float> @llvm.dx.cross.v3f32(<3 x float>, <3 x float>)
\r
8 define noundef <3 x half> @test_cross_half3(<3 x half> noundef %p0, <3 x half> noundef %p1) {
\r
10 ; CHECK: %x0 = extractelement <3 x half> %p0, i64 0
\r
11 ; CHECK: %x1 = extractelement <3 x half> %p0, i64 1
\r
12 ; CHECK: %x2 = extractelement <3 x half> %p0, i64 2
\r
13 ; CHECK: %y0 = extractelement <3 x half> %p1, i64 0
\r
14 ; CHECK: %y1 = extractelement <3 x half> %p1, i64 1
\r
15 ; CHECK: %y2 = extractelement <3 x half> %p1, i64 2
\r
16 ; CHECK: %0 = fmul half %x1, %y2
\r
17 ; CHECK: %1 = fmul half %x2, %y1
\r
18 ; CHECK: %hlsl.cross1 = fsub half %0, %1
\r
19 ; CHECK: %2 = fmul half %x2, %y0
\r
20 ; CHECK: %3 = fmul half %x0, %y2
\r
21 ; CHECK: %hlsl.cross2 = fsub half %2, %3
\r
22 ; CHECK: %4 = fmul half %x0, %y1
\r
23 ; CHECK: %5 = fmul half %x1, %y0
\r
24 ; CHECK: %hlsl.cross3 = fsub half %4, %5
\r
25 ; CHECK: %6 = insertelement <3 x half> undef, half %hlsl.cross1, i64 0
\r
26 ; CHECK: %7 = insertelement <3 x half> %6, half %hlsl.cross2, i64 1
\r
27 ; CHECK: %8 = insertelement <3 x half> %7, half %hlsl.cross3, i64 2
\r
28 ; CHECK: ret <3 x half> %8
\r
29 %hlsl.cross = call <3 x half> @llvm.dx.cross.v3f16(<3 x half> %p0, <3 x half> %p1)
\r
30 ret <3 x half> %hlsl.cross
\r
33 define noundef <3 x float> @test_cross_float3(<3 x float> noundef %p0, <3 x float> noundef %p1) {
\r
35 ; CHECK: %x0 = extractelement <3 x float> %p0, i64 0
\r
36 ; CHECK: %x1 = extractelement <3 x float> %p0, i64 1
\r
37 ; CHECK: %x2 = extractelement <3 x float> %p0, i64 2
\r
38 ; CHECK: %y0 = extractelement <3 x float> %p1, i64 0
\r
39 ; CHECK: %y1 = extractelement <3 x float> %p1, i64 1
\r
40 ; CHECK: %y2 = extractelement <3 x float> %p1, i64 2
\r
41 ; CHECK: %0 = fmul float %x1, %y2
\r
42 ; CHECK: %1 = fmul float %x2, %y1
\r
43 ; CHECK: %hlsl.cross1 = fsub float %0, %1
\r
44 ; CHECK: %2 = fmul float %x2, %y0
\r
45 ; CHECK: %3 = fmul float %x0, %y2
\r
46 ; CHECK: %hlsl.cross2 = fsub float %2, %3
\r
47 ; CHECK: %4 = fmul float %x0, %y1
\r
48 ; CHECK: %5 = fmul float %x1, %y0
\r
49 ; CHECK: %hlsl.cross3 = fsub float %4, %5
\r
50 ; CHECK: %6 = insertelement <3 x float> undef, float %hlsl.cross1, i64 0
\r
51 ; CHECK: %7 = insertelement <3 x float> %6, float %hlsl.cross2, i64 1
\r
52 ; CHECK: %8 = insertelement <3 x float> %7, float %hlsl.cross3, i64 2
\r
53 ; CHECK: ret <3 x float> %8
\r
54 %hlsl.cross = call <3 x float> @llvm.dx.cross.v3f32(<3 x float> %p0, <3 x float> %p1)
\r
55 ret <3 x float> %hlsl.cross
\r