Skip to content

Commit c098435

Browse files
authored
Add cross builtins and cross HLSL function to DirectX and SPIR-V backend (#109180)
This PR adds the step intrinsic and an HLSL function that uses it. The SPIRV backend is also implemented. Used #106471 as a reference. Fixes #99095
1 parent 1b4b0c4 commit c098435

File tree

15 files changed

+299
-5
lines changed

15 files changed

+299
-5
lines changed

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4739,6 +4739,12 @@ def HLSLClamp : LangBuiltin<"HLSL_LANG"> {
47394739
let Prototype = "void(...)";
47404740
}
47414741

4742+
def HLSLCross: LangBuiltin<"HLSL_LANG"> {
4743+
let Spellings = ["__builtin_hlsl_cross"];
4744+
let Attributes = [NoThrow, Const];
4745+
let Prototype = "void(...)";
4746+
}
4747+
47424748
def HLSLDotProduct : LangBuiltin<"HLSL_LANG"> {
47434749
let Spellings = ["__builtin_hlsl_dot"];
47444750
let Attributes = [NoThrow, Const];

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10510,8 +10510,8 @@ def err_first_argument_to_cwsc_pdtor_call : Error<
1051010510
def err_second_argument_to_cwsc_not_pointer : Error<
1051110511
"second argument to __builtin_call_with_static_chain must be of pointer type">;
1051210512

10513-
def err_vector_incorrect_num_initializers : Error<
10514-
"%select{too many|too few}0 elements in vector initialization (expected %1 elements, have %2)">;
10513+
def err_vector_incorrect_num_elements : Error<
10514+
"%select{too many|too few}0 elements in vector %select{initialization|operand}3 (expected %1 elements, have %2)">;
1051510515
def err_altivec_empty_initializer : Error<"expected initializer">;
1051610516

1051710517
def err_invalid_neon_type_code : Error<

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18667,6 +18667,21 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
1866718667
IsUnsigned ? Intrinsic::dx_uclamp : Intrinsic::dx_clamp,
1866818668
ArrayRef<Value *>{OpX, OpMin, OpMax}, nullptr, "dx.clamp");
1866918669
}
18670+
case Builtin::BI__builtin_hlsl_cross: {
18671+
Value *Op0 = EmitScalarExpr(E->getArg(0));
18672+
Value *Op1 = EmitScalarExpr(E->getArg(1));
18673+
assert(E->getArg(0)->getType()->hasFloatingRepresentation() &&
18674+
E->getArg(1)->getType()->hasFloatingRepresentation() &&
18675+
"cross operands must have a float representation");
18676+
// make sure each vector has exactly 3 elements
18677+
auto *XVecTy1 = E->getArg(0)->getType()->getAs<VectorType>();
18678+
auto *XVecTy2 = E->getArg(1)->getType()->getAs<VectorType>();
18679+
assert(XVecTy1->getNumElements() == 3 && XVecTy2->getNumElements() == 3 &&
18680+
"input vectors must have 3 elements each");
18681+
return Builder.CreateIntrinsic(
18682+
/*ReturnType=*/Op0->getType(), CGM.getHLSLRuntime().getCrossIntrinsic(),
18683+
ArrayRef<Value *>{Op0, Op1}, nullptr, "hlsl.cross");
18684+
}
1867018685
case Builtin::BI__builtin_hlsl_dot: {
1867118686
Value *Op0 = EmitScalarExpr(E->getArg(0));
1867218687
Value *Op1 = EmitScalarExpr(E->getArg(1));

clang/lib/CodeGen/CGHLSLRuntime.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class CGHLSLRuntime {
7474

7575
GENERATE_HLSL_INTRINSIC_FUNCTION(All, all)
7676
GENERATE_HLSL_INTRINSIC_FUNCTION(Any, any)
77+
GENERATE_HLSL_INTRINSIC_FUNCTION(Cross, cross)
7778
GENERATE_HLSL_INTRINSIC_FUNCTION(Frac, frac)
7879
GENERATE_HLSL_INTRINSIC_FUNCTION(Length, length)
7980
GENERATE_HLSL_INTRINSIC_FUNCTION(Lerp, lerp)

clang/lib/Headers/hlsl/hlsl_intrinsics.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,28 @@ uint64_t3 reversebits(uint64_t3);
16421642
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
16431643
uint64_t4 reversebits(uint64_t4);
16441644

1645+
//===----------------------------------------------------------------------===//
1646+
// cross builtins
1647+
//===----------------------------------------------------------------------===//
1648+
1649+
/// \fn T cross(T x, T y)
1650+
/// \brief Returns the cross product of two floating-point, 3D vectors.
1651+
/// \param x [in] The first floating-point, 3D vector.
1652+
/// \param y [in] The second floating-point, 3D vector.
1653+
///
1654+
/// Result is the cross product of x and y, i.e., the resulting
1655+
/// components are, in order :
1656+
/// x[1] * y[2] - y[1] * x[2]
1657+
/// x[2] * y[0] - y[2] * x[0]
1658+
/// x[0] * y[1] - y[0] * x[1]
1659+
1660+
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1661+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_cross)
1662+
half3 cross(half3, half3);
1663+
1664+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_cross)
1665+
float3 cross(float3, float3);
1666+
16451667
//===----------------------------------------------------------------------===//
16461668
// rcp builtins
16471669
//===----------------------------------------------------------------------===//

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,41 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
18281828
return true;
18291829
break;
18301830
}
1831+
case Builtin::BI__builtin_hlsl_cross: {
1832+
if (SemaRef.checkArgCount(TheCall, 2))
1833+
return true;
1834+
if (CheckVectorElementCallArgs(&SemaRef, TheCall))
1835+
return true;
1836+
if (CheckFloatOrHalfRepresentations(&SemaRef, TheCall))
1837+
return true;
1838+
// ensure both args have 3 elements
1839+
int NumElementsArg1 =
1840+
TheCall->getArg(0)->getType()->getAs<VectorType>()->getNumElements();
1841+
int NumElementsArg2 =
1842+
TheCall->getArg(1)->getType()->getAs<VectorType>()->getNumElements();
1843+
1844+
if (NumElementsArg1 != 3) {
1845+
int LessOrMore = NumElementsArg1 > 3 ? 1 : 0;
1846+
SemaRef.Diag(TheCall->getBeginLoc(),
1847+
diag::err_vector_incorrect_num_elements)
1848+
<< LessOrMore << 3 << NumElementsArg1 << /*operand*/ 1;
1849+
return true;
1850+
}
1851+
if (NumElementsArg2 != 3) {
1852+
int LessOrMore = NumElementsArg2 > 3 ? 1 : 0;
1853+
1854+
SemaRef.Diag(TheCall->getBeginLoc(),
1855+
diag::err_vector_incorrect_num_elements)
1856+
<< LessOrMore << 3 << NumElementsArg2 << /*operand*/ 1;
1857+
return true;
1858+
}
1859+
1860+
ExprResult A = TheCall->getArg(0);
1861+
QualType ArgTyA = A.get()->getType();
1862+
// return type is the same as the input type
1863+
TheCall->setType(ArgTyA);
1864+
break;
1865+
}
18311866
case Builtin::BI__builtin_hlsl_dot: {
18321867
if (SemaRef.checkArgCount(TheCall, 2))
18331868
return true;

clang/lib/Sema/SemaInit.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,8 +1976,9 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity,
19761976
if (numEltsInit != maxElements) {
19771977
if (!VerifyOnly)
19781978
SemaRef.Diag(IList->getBeginLoc(),
1979-
diag::err_vector_incorrect_num_initializers)
1980-
<< (numEltsInit < maxElements) << maxElements << numEltsInit;
1979+
diag::err_vector_incorrect_num_elements)
1980+
<< (numEltsInit < maxElements) << maxElements << numEltsInit
1981+
<< /*initialization*/ 0;
19811982
hadError = true;
19821983
}
19831984
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
2+
// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \
3+
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
4+
// RUN: --check-prefixes=CHECK,NATIVE_HALF \
5+
// RUN: -DFNATTRS=noundef -DTARGET=dx
6+
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
7+
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
8+
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF \
9+
// RUN: -DFNATTRS=noundef -DTARGET=dx
10+
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
11+
// RUN: spirv-unknown-vulkan-compute %s -fnative-half-type \
12+
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
13+
// RUN: --check-prefixes=CHECK,NATIVE_HALF \
14+
// RUN: -DFNATTRS="spir_func noundef" -DTARGET=spv
15+
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
16+
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
17+
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF \
18+
// RUN: -DFNATTRS="spir_func noundef" -DTARGET=spv
19+
20+
// NATIVE_HALF: define [[FNATTRS]] <3 x half> @
21+
// NATIVE_HALF: call <3 x half> @llvm.[[TARGET]].cross.v3f16(<3 x half>
22+
// NATIVE_HALF: ret <3 x half> %hlsl.cross
23+
// NO_HALF: define [[FNATTRS]] <3 x float> @
24+
// NO_HALF: call <3 x float> @llvm.[[TARGET]].cross.v3f32(<3 x float>
25+
// NO_HALF: ret <3 x float> %hlsl.cross
26+
half3 test_cross_half3(half3 p0, half3 p1)
27+
{
28+
return cross(p0, p1);
29+
}
30+
31+
// CHECK: define [[FNATTRS]] <3 x float> @
32+
// CHECK: %hlsl.cross = call <3 x float> @llvm.[[TARGET]].cross.v3f32(
33+
// CHECK: ret <3 x float> %hlsl.cross
34+
float3 test_cross_float3(float3 p0, float3 p1)
35+
{
36+
return cross(p0, p1);
37+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -disable-llvm-passes -verify
2+
3+
void test_too_few_arg()
4+
{
5+
return __builtin_hlsl_cross();
6+
// expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
7+
}
8+
9+
void test_too_many_arg(float3 p0)
10+
{
11+
return __builtin_hlsl_cross(p0, p0, p0);
12+
// expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
13+
}
14+
15+
bool builtin_bool_to_float_type_promotion(bool p1)
16+
{
17+
return __builtin_hlsl_cross(p1, p1);
18+
// expected-error@-1 {{passing 'bool' to parameter of incompatible type 'float'}}
19+
}
20+
21+
bool builtin_cross_int_to_float_promotion(int p1)
22+
{
23+
return __builtin_hlsl_cross(p1, p1);
24+
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}}
25+
}
26+
27+
bool2 builtin_cross_int2_to_float2_promotion(int2 p1)
28+
{
29+
return __builtin_hlsl_cross(p1, p1);
30+
// expected-error@-1 {{passing 'int2' (aka 'vector<int, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}
31+
}
32+
33+
float2 builtin_cross_float2(float2 p1, float2 p2)
34+
{
35+
return __builtin_hlsl_cross(p1, p2);
36+
// expected-error@-1 {{too many elements in vector operand (expected 3 elements, have 2)}}
37+
}
38+
39+
float3 builtin_cross_float3_int3(float3 p1, int3 p2)
40+
{
41+
return __builtin_hlsl_cross(p1, p2);
42+
// expected-error@-1 {{all arguments to '__builtin_hlsl_cross' must have the same type}}
43+
}

llvm/include/llvm/IR/IntrinsicsDirectX.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def int_dx_all : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty], [IntrNoMem]>
4242
def int_dx_any : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty], [IntrNoMem]>;
4343
def int_dx_clamp : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
4444
def int_dx_uclamp : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
45+
def int_dx_cross : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
4546
def int_dx_saturate : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>], [IntrNoMem]>;
4647

4748
def int_dx_dot2 :

llvm/include/llvm/IR/IntrinsicsSPIRV.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ let TargetPrefix = "spv" in {
6161
def int_spv_thread_id : Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem, IntrWillReturn]>;
6262
def int_spv_all : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty], [IntrNoMem]>;
6363
def int_spv_any : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty], [IntrNoMem]>;
64+
def int_spv_cross : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
6465
def int_spv_frac : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty], [IntrNoMem]>;
6566
def int_spv_lerp : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty, LLVMMatchType<0>,LLVMMatchType<0>],
6667
[IntrNoMem] >;

llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ static bool isIntrinsicExpansion(Function &F) {
5454
case Intrinsic::dx_all:
5555
case Intrinsic::dx_any:
5656
case Intrinsic::dx_clamp:
57+
case Intrinsic::dx_cross:
5758
case Intrinsic::dx_uclamp:
5859
case Intrinsic::dx_lerp:
5960
case Intrinsic::dx_length:
@@ -84,6 +85,42 @@ static Value *expandAbs(CallInst *Orig) {
8485
"dx.max");
8586
}
8687

88+
static Value *expandCrossIntrinsic(CallInst *Orig) {
89+
90+
VectorType *VT = cast<VectorType>(Orig->getType());
91+
if (cast<FixedVectorType>(VT)->getNumElements() != 3)
92+
report_fatal_error(Twine("return vector must have exactly 3 elements"),
93+
/* gen_crash_diag=*/false);
94+
95+
Value *op0 = Orig->getOperand(0);
96+
Value *op1 = Orig->getOperand(1);
97+
IRBuilder<> Builder(Orig);
98+
99+
Value *op0_x = Builder.CreateExtractElement(op0, (uint64_t)0, "x0");
100+
Value *op0_y = Builder.CreateExtractElement(op0, 1, "x1");
101+
Value *op0_z = Builder.CreateExtractElement(op0, 2, "x2");
102+
103+
Value *op1_x = Builder.CreateExtractElement(op1, (uint64_t)0, "y0");
104+
Value *op1_y = Builder.CreateExtractElement(op1, 1, "y1");
105+
Value *op1_z = Builder.CreateExtractElement(op1, 2, "y2");
106+
107+
auto MulSub = [&](Value *x0, Value *y0, Value *x1, Value *y1) -> Value * {
108+
Value *xy = Builder.CreateFMul(x0, y1);
109+
Value *yx = Builder.CreateFMul(y0, x1);
110+
return Builder.CreateFSub(xy, yx, Orig->getName());
111+
};
112+
113+
Value *yz_zy = MulSub(op0_y, op0_z, op1_y, op1_z);
114+
Value *zx_xz = MulSub(op0_z, op0_x, op1_z, op1_x);
115+
Value *xy_yx = MulSub(op0_x, op0_y, op1_x, op1_y);
116+
117+
Value *cross = UndefValue::get(VT);
118+
cross = Builder.CreateInsertElement(cross, yz_zy, (uint64_t)0);
119+
cross = Builder.CreateInsertElement(cross, zx_xz, 1);
120+
cross = Builder.CreateInsertElement(cross, xy_yx, 2);
121+
return cross;
122+
}
123+
87124
// Create appropriate DXIL float dot intrinsic for the given A and B operands
88125
// The appropriate opcode will be determined by the size of the operands
89126
// The dot product is placed in the position indicated by Orig
@@ -496,6 +533,9 @@ static bool expandIntrinsic(Function &F, CallInst *Orig) {
496533
case Intrinsic::dx_any:
497534
Result = expandAnyOrAllIntrinsic(Orig, IntrinsicId);
498535
break;
536+
case Intrinsic::dx_cross:
537+
Result = expandCrossIntrinsic(Orig);
538+
break;
499539
case Intrinsic::dx_uclamp:
500540
case Intrinsic::dx_clamp:
501541
Result = expandClampIntrinsic(Orig, IntrinsicId);

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ class SPIRVInstructionSelector : public InstructionSelector {
145145

146146
bool selectCmp(Register ResVReg, const SPIRVType *ResType,
147147
unsigned comparisonOpcode, MachineInstr &I) const;
148-
148+
bool selectCross(Register ResVReg, const SPIRVType *ResType,
149+
MachineInstr &I) const;
149150
bool selectICmp(Register ResVReg, const SPIRVType *ResType,
150151
MachineInstr &I) const;
151152
bool selectFCmp(Register ResVReg, const SPIRVType *ResType,
@@ -2500,6 +2501,8 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
25002501
return selectAll(ResVReg, ResType, I);
25012502
case Intrinsic::spv_any:
25022503
return selectAny(ResVReg, ResType, I);
2504+
case Intrinsic::spv_cross:
2505+
return selectExtInst(ResVReg, ResType, I, CL::cross, GL::Cross);
25032506
case Intrinsic::spv_lerp:
25042507
return selectExtInst(ResVReg, ResType, I, CL::mix, GL::FMix);
25052508
case Intrinsic::spv_length:

llvm/test/CodeGen/DirectX/cross.ll

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
5+
declare <3 x half> @llvm.dx.cross.v3f16(<3 x half>, <3 x half>)
6+
declare <3 x float> @llvm.dx.cross.v3f32(<3 x float>, <3 x float>)
7+
8+
define noundef <3 x half> @test_cross_half3(<3 x half> noundef %p0, <3 x half> noundef %p1) {
9+
entry:
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+
33+
define noundef <3 x float> @test_cross_float3(<3 x float> noundef %p0, <3 x float> noundef %p1) {
34+
entry:
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+
}

0 commit comments

Comments
 (0)