Skip to content

Commit 4365160

Browse files
pauzinlvmaksimo
authored andcommitted
Store result of fixed point integer SPIR-V instructions wider than 64 bits (intel#1244)
This if fix for intel#1213 This patch adds Store instructions in cases when return value is wider than 64 bits Original commit: KhronosGroup/SPIRV-LLVM-Translator@7904ea9
1 parent 3376c14 commit 4365160

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

+18-6
Original file line numberDiff line numberDiff line change
@@ -4180,8 +4180,12 @@ LLVMToSPIRVBase::transBuiltinToInstWithoutDecoration(Op OC, CallInst *CI,
41804180
return cast<llvm::ConstantInt>(O)->getZExtValue();
41814181
});
41824182

4183-
return BM->addFixedPointIntelInst(OC, transType(ResTy), Input, Literals,
4184-
BB);
4183+
auto *APIntInst =
4184+
BM->addFixedPointIntelInst(OC, transType(ResTy), Input, Literals, BB);
4185+
if (!CI->hasStructRetAttr())
4186+
return APIntInst;
4187+
return BM->addStoreInst(transValue(CI->getArgOperand(0), BB), APIntInst, {},
4188+
BB);
41854189
}
41864190
case OpArbitraryFloatCastINTEL:
41874191
case OpArbitraryFloatCastFromIntINTEL:
@@ -4263,8 +4267,12 @@ LLVMToSPIRVBase::transBuiltinToInstWithoutDecoration(Op OC, CallInst *CI,
42634267
return cast<llvm::ConstantInt>(O)->getZExtValue();
42644268
});
42654269

4266-
return BM->addArbFloatPointIntelInst(OC, transType(ResTy), InA, nullptr,
4267-
Literals, BB);
4270+
auto *APIntInst = BM->addArbFloatPointIntelInst(OC, transType(ResTy), InA,
4271+
nullptr, Literals, BB);
4272+
if (!CI->hasStructRetAttr())
4273+
return APIntInst;
4274+
return BM->addStoreInst(transValue(CI->getArgOperand(0), BB), APIntInst, {},
4275+
BB);
42684276
}
42694277
case OpArbitraryFloatAddINTEL:
42704278
case OpArbitraryFloatSubINTEL:
@@ -4335,8 +4343,12 @@ LLVMToSPIRVBase::transBuiltinToInstWithoutDecoration(Op OC, CallInst *CI,
43354343
return cast<llvm::ConstantInt>(O)->getZExtValue();
43364344
});
43374345

4338-
return BM->addArbFloatPointIntelInst(OC, transType(ResTy), InA, InB,
4339-
Literals, BB);
4346+
auto *APIntInst = BM->addArbFloatPointIntelInst(OC, transType(ResTy), InA,
4347+
InB, Literals, BB);
4348+
if (!CI->hasStructRetAttr())
4349+
return APIntInst;
4350+
return BM->addStoreInst(transValue(CI->getArgOperand(0), BB), APIntInst, {},
4351+
BB);
43404352
}
43414353
default: {
43424354
if (isCvtOpCode(OC) && OC != OpGenericCastToPtrExplicit) {

llvm-spirv/test/transcoding/capability-arbitrary-precision-fixed-point-numbers.ll

+2-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@
164164
; CHECK-SPIRV-NEXT: 9 FixedExpINTEL [[Ty_34]] [[#]] [[Exp_InId]] 0 20 20 0 0
165165

166166
; CHECK-SPIRV: 6 Load [[Ty_34]] [[SinCos_InId:[0-9]+]]
167-
; CHECK-SPIRV-NEXT: 9 FixedSinCosINTEL [[Ty_66]] [[#]] [[SinCos_InId]] 1 3 2 0 0
167+
; CHECK-SPIRV-NEXT: 9 FixedSinCosINTEL [[Ty_66]] [[SinCos_ResultId:[0-9]+]] [[SinCos_InId]] 1 3 2 0 0
168+
; CHECK-SPIRV: 3 Store [[#]] [[SinCos_ResultId]]
168169

169170
; CHECK-LLVM: call i5 @intel_arbitrary_fixed_sqrt.i5.i13(i13 %[[#]], i1 false, i32 2, i32 2, i32 0, i32 0)
170171
; CHECK-LLVM: call i13 @intel_arbitrary_fixed_sqrt.i13.i5(i5 %[[#]], i1 false, i32 2, i32 2, i32 0, i32 0)

llvm-spirv/test/transcoding/capability-arbitrary-precision-floating-point.ll

+4-2
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,8 @@ define linkonce_odr dso_local spir_func void @_Z15ap_float_sincosILi8ELi18ELi10E
15781578
%7 = load i34, i34 addrspace(4)* %2, align 8
15791579
call spir_func void @_Z33__spirv_ArbitraryFloatSinCosINTELILi34ELi66EEU7_ExtIntIXmlLi2ET0_EEiU7_ExtIntIXT_EEiiiiii(i66 addrspace(4)* sret(i66) align 8 %4, i34 %7, i32 18, i32 20, i32 0, i32 2, i32 1) #5
15801580
; CHECK-SPIRV: 6 Load [[Ty_34]] [[SinCos_AId:[0-9]+]]
1581-
; CHECK-SPIRV-NEXT: 9 ArbitraryFloatSinCosINTEL [[Ty_66]] [[#]] [[SinCos_AId]] 18 20 0 2 1
1581+
; CHECK-SPIRV-NEXT: 9 ArbitraryFloatSinCosINTEL [[Ty_66]] [[SinCos_ResultId:[0-9]+]] [[SinCos_AId]] 18 20 0 2 1
1582+
; CHECK-SPIRV: 3 Store [[#]] [[SinCos_ResultId]]
15821583
; CHECK-LLVM: call i66 @intel_arbitrary_float_sincos.i66.i34(i34 %[[#]], i32 18, i32 20, i32 0, i32 2, i32 1)
15831584
%8 = load i66, i66 addrspace(4)* %4, align 8
15841585
store i66 %8, i66 addrspace(4)* %4, align 8
@@ -1606,7 +1607,8 @@ define linkonce_odr dso_local spir_func void @_Z14ap_float_atan2ILi7ELi16ELi7ELi
16061607
call spir_func void @_Z32__spirv_ArbitraryFloatATan2INTELILi24ELi25ELi66EEU7_ExtIntIXT1_EEiU7_ExtIntIXT_EEiiU7_ExtIntIXT0_EEiiiiii(i66 addrspace(4)* sret(i66) align 8 %4, i24 signext %8, i32 16, i25 signext %9, i32 17, i32 18, i32 0, i32 2, i32 1) #5
16071608
; CHECK-SPIRV: 6 Load [[Ty_24]] [[ATan2_AId:[0-9]+]]
16081609
; CHECK-SPIRV-NEXT: 6 Load [[Ty_25]] [[ATan2_BId:[0-9]+]]
1609-
; CHECK-SPIRV-NEXT: 11 ArbitraryFloatATan2INTEL [[Ty_66]] [[#]] [[ATan2_AId]] 16 [[ATan2_BId]] 17 18 0 2 1
1610+
; CHECK-SPIRV-NEXT: 11 ArbitraryFloatATan2INTEL [[Ty_66]] [[ATan2_ResultId:[0-9]+]] [[ATan2_AId]] 16 [[ATan2_BId]] 17 18 0 2 1
1611+
; CHECK-SPIRV: 3 Store [[#]] [[ATan2_ResultId]]
16101612
; CHECK-LLVM: call i66 @intel_arbitrary_float_atan2.i66.i24.i25(i24 %[[#]], i32 16, i25 %[[#]], i32 17, i32 18, i32 0, i32 2, i32 1)
16111613
%10 = load i66, i66 addrspace(4)* %4, align 8
16121614
store i66 %10, i66 addrspace(4)* %4, align 8

0 commit comments

Comments
 (0)