Skip to content

Commit 7904ea9

Browse files
author
Leonid Pauzin
authored
Store result of fixed point integer SPIR-V instructions wider than 64 bits (#1244)
This if fix for #1213 This patch adds Store instructions in cases when return value is wider than 64 bits
1 parent 4c634db commit 7904ea9

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4160,8 +4160,12 @@ LLVMToSPIRVBase::transBuiltinToInstWithoutDecoration(Op OC, CallInst *CI,
41604160
return cast<llvm::ConstantInt>(O)->getZExtValue();
41614161
});
41624162

4163-
return BM->addFixedPointIntelInst(OC, transType(ResTy), Input, Literals,
4164-
BB);
4163+
auto *APIntInst =
4164+
BM->addFixedPointIntelInst(OC, transType(ResTy), Input, Literals, BB);
4165+
if (!CI->hasStructRetAttr())
4166+
return APIntInst;
4167+
return BM->addStoreInst(transValue(CI->getArgOperand(0), BB), APIntInst, {},
4168+
BB);
41654169
}
41664170
case OpArbitraryFloatCastINTEL:
41674171
case OpArbitraryFloatCastFromIntINTEL:
@@ -4243,8 +4247,12 @@ LLVMToSPIRVBase::transBuiltinToInstWithoutDecoration(Op OC, CallInst *CI,
42434247
return cast<llvm::ConstantInt>(O)->getZExtValue();
42444248
});
42454249

4246-
return BM->addArbFloatPointIntelInst(OC, transType(ResTy), InA, nullptr,
4247-
Literals, BB);
4250+
auto *APIntInst = BM->addArbFloatPointIntelInst(OC, transType(ResTy), InA,
4251+
nullptr, Literals, BB);
4252+
if (!CI->hasStructRetAttr())
4253+
return APIntInst;
4254+
return BM->addStoreInst(transValue(CI->getArgOperand(0), BB), APIntInst, {},
4255+
BB);
42484256
}
42494257
case OpArbitraryFloatAddINTEL:
42504258
case OpArbitraryFloatSubINTEL:
@@ -4315,8 +4323,12 @@ LLVMToSPIRVBase::transBuiltinToInstWithoutDecoration(Op OC, CallInst *CI,
43154323
return cast<llvm::ConstantInt>(O)->getZExtValue();
43164324
});
43174325

4318-
return BM->addArbFloatPointIntelInst(OC, transType(ResTy), InA, InB,
4319-
Literals, BB);
4326+
auto *APIntInst = BM->addArbFloatPointIntelInst(OC, transType(ResTy), InA,
4327+
InB, Literals, BB);
4328+
if (!CI->hasStructRetAttr())
4329+
return APIntInst;
4330+
return BM->addStoreInst(transValue(CI->getArgOperand(0), BB), APIntInst, {},
4331+
BB);
43204332
}
43214333
default: {
43224334
if (isCvtOpCode(OC) && OC != OpGenericCastToPtrExplicit) {

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

Lines changed: 2 additions & 1 deletion
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)

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

Lines changed: 4 additions & 2 deletions
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)