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