Skip to content

Commit ab3f61a

Browse files
authored
Revert "Align translation of OpCooperativeMatrixLengthKHR to match the spec" (#17192)
This reverts commit 45da762. And resolves #17079 The change should be relanded once the OCL CPU RT driver is updated.
1 parent 194ec74 commit ab3f61a

File tree

7 files changed

+8
-22
lines changed

7 files changed

+8
-22
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3627,7 +3627,8 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName,
36273627
Func->addFnAttr(Attribute::Convergent);
36283628
}
36293629
CallInst *Call;
3630-
if (OC == OpCooperativeMatrixLengthKHR) {
3630+
if (OC == OpCooperativeMatrixLengthKHR &&
3631+
Ops[0]->getOpCode() == OpTypeCooperativeMatrixKHR) {
36313632
// OpCooperativeMatrixLengthKHR needs special handling as its operand is
36323633
// a Type instead of a Value.
36333634
llvm::Type *MatTy = transType(reinterpret_cast<SPIRVType *>(Ops[0]));

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6787,10 +6787,6 @@ LLVMToSPIRVBase::transBuiltinToInstWithoutDecoration(Op OC, CallInst *CI,
67876787
transValue(CI->getArgOperand(2), BB), BB);
67886788
return BM->addStoreInst(transValue(CI->getArgOperand(0), BB), V, {}, BB);
67896789
}
6790-
case OpCooperativeMatrixLengthKHR: {
6791-
return BM->addCooperativeMatrixLengthKHRInst(
6792-
transScavengedType(CI), transType(CI->getArgOperand(0)->getType()), BB);
6793-
}
67946790
case OpGroupNonUniformShuffleDown: {
67956791
Function *F = CI->getCalledFunction();
67966792
if (F->arg_size() && F->getArg(0)->hasStructRetAttr()) {

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVModule.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,6 @@ class SPIRVModuleImpl : public SPIRVModule {
279279
SPIRVTypeTaskSequenceINTEL *addTaskSequenceINTELType() override;
280280
SPIRVInstruction *addTaskSequenceGetINTELInst(SPIRVType *, SPIRVValue *,
281281
SPIRVBasicBlock *) override;
282-
SPIRVInstruction *
283-
addCooperativeMatrixLengthKHRInst(SPIRVType *, SPIRVType *,
284-
SPIRVBasicBlock *) override;
285282
SPIRVType *addOpaqueGenericType(Op) override;
286283
SPIRVTypeDeviceEvent *addDeviceEventType() override;
287284
SPIRVTypeQueue *addQueueType() override;
@@ -1097,14 +1094,6 @@ SPIRVInstruction *SPIRVModuleImpl::addTaskSequenceGetINTELInst(
10971094
BB);
10981095
}
10991096

1100-
SPIRVInstruction *SPIRVModuleImpl::addCooperativeMatrixLengthKHRInst(
1101-
SPIRVType *RetTy, SPIRVType *MatTy, SPIRVBasicBlock *BB) {
1102-
return addInstruction(
1103-
SPIRVInstTemplateBase::create(OpCooperativeMatrixLengthKHR, RetTy,
1104-
getId(), getVec(MatTy->getId()), BB, this),
1105-
BB);
1106-
}
1107-
11081097
SPIRVType *SPIRVModuleImpl::addOpaqueGenericType(Op TheOpCode) {
11091098
return addType(new SPIRVTypeOpaqueGeneric(TheOpCode, this, getId()));
11101099
}

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVModule.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,6 @@ class SPIRVModule {
272272
virtual SPIRVTypeTaskSequenceINTEL *addTaskSequenceINTELType() = 0;
273273
virtual SPIRVInstruction *
274274
addTaskSequenceGetINTELInst(SPIRVType *, SPIRVValue *, SPIRVBasicBlock *) = 0;
275-
virtual SPIRVInstruction *
276-
addCooperativeMatrixLengthKHRInst(SPIRVType *, SPIRVType *,
277-
SPIRVBasicBlock *) = 0;
278275
virtual SPIRVTypeVoid *addVoidType() = 0;
279276
virtual SPIRVType *addOpaqueGenericType(Op) = 0;
280277
virtual SPIRVTypeDeviceEvent *addDeviceEventType() = 0;

llvm-spirv/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_checked.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
; CHECK-SPIRV-DAG: TypeCooperativeMatrixKHR [[#MatTy3:]] [[#Int8Ty]] [[#Const2]] [[#Const48]] [[#Const12]] [[#Const1]]
3333
; CHECK-SPIRV: CooperativeMatrixConstructCheckedINTEL [[#MatTy1]]
3434
; CHECK-SPIRV: CooperativeMatrixLoadCheckedINTEL [[#MatTy2]] [[#Load1:]]
35-
; CHECK-SPIRV: CooperativeMatrixLengthKHR [[#Int32Ty]] [[#]] [[#MatTy2]]
35+
; TODO: Pass Matrix Type Id instead of Matrix Id to CooperativeMatrixLengthKHR.
36+
; CHECK-SPIRV: CooperativeMatrixLengthKHR [[#Int32Ty]] [[#]] [[#Load1]]
3637
; CHECK-SPIRV: CooperativeMatrixLoadCheckedINTEL [[#MatTy3]]
3738
; CHECK-SPIRV: CooperativeMatrixMulAddKHR [[#MatTy1]]
3839
; CHECK-SPIRV: CooperativeMatrixStoreCheckedINTEL

llvm-spirv/test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_prefetch.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
; CHECK-SPIRV-DAG: TypeCooperativeMatrixKHR [[#MatTy3:]] [[#Int8Ty]] [[#Const2]] [[#Const48]] [[#Const12]] [[#Const1]]
3333
; CHECK-SPIRV: CompositeConstruct [[#MatTy1]]
3434
; CHECK-SPIRV: CooperativeMatrixLoadKHR [[#MatTy2]] [[#Load1:]]
35-
; CHECK-SPIRV: CooperativeMatrixLengthKHR [[#Int32Ty]] [[#]] [[#MatTy2]]
35+
; TODO: Pass Matrix Type Id instead of Matrix Id to CooperativeMatrixLengthKHR.
36+
; CHECK-SPIRV: CooperativeMatrixLengthKHR [[#Int32Ty]] [[#]] [[#Load1]]
3637
; CHECK-SPIRV: CooperativeMatrixPrefetchINTEL
3738
; CHECK-SPIRV: CooperativeMatrixLoadKHR [[#MatTy3]]
3839
; CHECK-SPIRV: CooperativeMatrixMulAddKHR [[#MatTy1]]

llvm-spirv/test/extensions/KHR/SPV_KHR_cooperative_matrix/cooperative_matrix.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
; CHECK-SPIRV-DAG: TypeCooperativeMatrixKHR [[#MatTy3:]] [[#Int8Ty]] [[#Const2]] [[#Const48]] [[#Const12]] [[#Const1]]
3131
; CHECK-SPIRV: CompositeConstruct [[#MatTy1]]
3232
; CHECK-SPIRV: CooperativeMatrixLoadKHR [[#MatTy2]] [[#Load1:]]
33-
; CHECK-SPIRV: CooperativeMatrixLengthKHR [[#Int32Ty]] [[#]] [[#MatTy2]]
33+
; TODO: Pass Matrix Type Id instead of Matrix Id to CooperativeMatrixLengthKHR.
34+
; CHECK-SPIRV: CooperativeMatrixLengthKHR [[#Int32Ty]] [[#]] [[#Load1]]
3435
; CHECK-SPIRV: CooperativeMatrixLoadKHR [[#MatTy3]]
3536
; CHECK-SPIRV: CooperativeMatrixMulAddKHR [[#MatTy1]]
3637
; CHECK-SPIRV: CooperativeMatrixStoreKHR

0 commit comments

Comments
 (0)