Skip to content

Commit cc0e9f3

Browse files
krystian-andrzejewskigfxbot
authored andcommitted
Revert of 27b6b89.
Change-Id: Ifb907ae61f2cb1eb151ba3cd9de7d2e0d2a577a4
1 parent 51fc17e commit cc0e9f3

File tree

6 files changed

+30
-40
lines changed

6 files changed

+30
-40
lines changed

IGC/Compiler/CISACodeGen/VectorPreProcess.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4141
using namespace llvm;
4242
using namespace IGC;
4343

44-
//
44+
//
4545
// Description of VectorPreProcess Pass
4646
// The purpose is both to legalize vector types and to reduce register
4747
// presure. Once this pass is done, there is no 3-element vector whose
@@ -53,7 +53,7 @@ using namespace IGC;
5353
// are either multiple of DW, vector3, or their size is less than
5454
// 4 bytes (see details in code). Vector3 will be specially
5555
// handled later.
56-
// For example,
56+
// For example,
5757
// <16xi64> ---> four <4xi64>
5858
// <15xi32> ---> <8xi32>, <7xi32>
5959
// <13xi32> ---> <8xi32>, <5xi32>
@@ -62,7 +62,7 @@ using namespace IGC;
6262
// <39xi8> ---> <32xi8>, <4xi8>, <3xi8>
6363
// Note that splitting keeps the vector element's type without
6464
// changing it.
65-
//
65+
//
6666
// 2. Special processing of 3-element vectors
6767
// If (vector element's size < 4 bytes)
6868
// {
@@ -91,11 +91,11 @@ using namespace IGC;
9191
//
9292
namespace
9393
{
94-
// AbstractLoadInst and AbstractStoreInst abstract away the differences
94+
// AbstractLoadInst and AbstractStoreInst abstract away the differences
9595
// between ldraw and Load and between storeraw and Store.
9696
// Note on usage: The Value* passed as the ptr paramter to the Create method
97-
// should be either the result of the getPointerOperand() method or the
98-
// CreateConstScalarGEP() method. Do not attempt to do arithmetic
97+
// should be either the result of the getPointerOperand() method or the
98+
// CreateConstScalarGEP() method. Do not attempt to do arithmetic
9999
// (or pointer arithmetic) on these values.
100100
class AbstractLoadInst
101101
{
@@ -223,7 +223,7 @@ namespace
223223
}
224224
unsigned int getAlignment() const
225225
{
226-
return isa<StoreInst>(m_inst) ? getStore()->getAlignment() : (unsigned int)llvm::cast<ConstantInt>(getStoreRaw()->getArgOperand(3))->getZExtValue();
226+
return isa<StoreInst>(m_inst) ? getStore()->getAlignment() : getStoreRaw()->getArgOperand(2)->getType()->getPrimitiveSizeInBits() / 8;
227227
}
228228
void setAlignment(unsigned int alignment)
229229
{
@@ -430,8 +430,8 @@ bool VectorPreProcess::isValueUsedOnlyByEEI(Value *V, ExtractElementInst **EEIns
430430
UI != UE; ++UI )
431431
{
432432
ExtractElementInst *EEI = dyn_cast<ExtractElementInst>(*UI);
433-
if( !EEI ||
434-
(EEI->getOperand(0) != V) ||
433+
if( !EEI ||
434+
(EEI->getOperand(0) != V) ||
435435
!isa<ConstantInt>(EEI->getOperand(1)) )
436436
{
437437
return false;
@@ -451,7 +451,7 @@ bool VectorPreProcess::isValueUsedOnlyByEEI(Value *V, ExtractElementInst **EEIns
451451

452452
// SVals[0:NumElements] has all scalar elements of vector VI. This function
453453
// tries to replace all uses of VI with SVals[...] if possible, If not
454-
// possible, re-generate the vector from SVals at the BB of VI.
454+
// possible, re-generate the vector from SVals at the BB of VI.
455455
//
456456
// This function also erase VI.
457457
void VectorPreProcess::replaceAllVectorUsesWithScalars(Instruction *VI, ValVector& SVals)
@@ -557,7 +557,7 @@ void VectorPreProcess::createSplitVectorTypes(
557557
++j;
558558
}
559559

560-
// Sub-vectors are
560+
// Sub-vectors are
561561
// 1. ebytes >=4, the remaing is a single sub-vector; or
562562
// 2. ebytes < 4, the remaining is splitted into
563563
// one sub-vector of multiple 4xebytes, and
@@ -694,7 +694,7 @@ bool VectorPreProcess::splitStore(AbstractStoreInst& ASI, V2SMap& vecToSubVec)
694694
bool IsVolatile = ASI.getIsVolatile();
695695
uint32_t eOffset = 0;
696696
uint32_t EBytes = int_cast<unsigned int>(m_DL->getTypeAllocSize(ETy));
697-
697+
698698
for (uint32_t i = 0, subIdx = 0; i < len; ++i)
699699
{
700700
VectorType *VTy1 = dyn_cast<VectorType>(tys[i]);
@@ -947,7 +947,7 @@ bool VectorPreProcess::splitVector3LoadStore(Instruction *Inst)
947947
Elt2 = ALI->Create(eTy, offsetAddr, newAlign, ALI->getIsVolatile());
948948
}
949949

950-
// A little optimization here
950+
// A little optimization here
951951
ExtractElementInst *EEInsts[3];
952952
for (int i = 0; i < 3; ++i)
953953
{
@@ -982,7 +982,7 @@ bool VectorPreProcess::splitVector3LoadStore(Instruction *Inst)
982982
ALI->getInst()->eraseFromParent();
983983
}
984984
else
985-
{
985+
{
986986
Value *Ptr = ASI->getPointerOperand();
987987
// Split 3-element into 2-element + 1 scalar
988988
Type *newVTy = VectorType::get(eTy, 2);
@@ -1088,7 +1088,7 @@ void VectorPreProcess::getOrGenScalarValues(
10881088
for (uint32_t i = 0; i < nelts; ++i)
10891089
{
10901090
scalars[i] = udv;
1091-
}
1091+
}
10921092
}
10931093
else if (ConstantVector* CV = dyn_cast<ConstantVector>(VecVal))
10941094
{
@@ -1148,7 +1148,7 @@ void VectorPreProcess::getOrGenScalarValues(
11481148
// VecVal is an argument or constant
11491149
inst_b = F.begin()->getFirstInsertionPt();
11501150
}
1151-
1151+
11521152
IRBuilder<> Builder(&(*inst_b));
11531153
for (uint32_t i = 0; i < nelts; ++i)
11541154
{

IGC/Compiler/CISACodeGen/helper.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,7 @@ Value* CreateStoreRawIntrinsic(StoreInst *inst, Instruction* bufPtr, Value* offs
304304
{
305305
bufPtr,
306306
offsetVal,
307-
storeVal,
308-
builder.getInt32(storeVal->getType()->getScalarSizeInBits() / 8)
307+
storeVal
309308
};
310309
Value* st = builder.CreateCall(func, attr);
311310
return st;

IGC/Compiler/FixResourcePtr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,7 @@ Value* FixResourcePtr::CreateStoreIntrinsic(StoreInst *inst, Instruction* bufPtr
357357
{
358358
bufPtr,
359359
offsetVal,
360-
storeVal,
361-
builder->getInt32(storeVal->getType()->getScalarSizeInBits() / 8)
360+
storeVal
362361
};
363362
Value* st = builder->CreateCall(l, attr);
364363
return st;

IGC/Compiler/PromoteResourceToDirectAS.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Value* GetBufferOperand(Instruction* inst)
117117
case GenISAIntrinsic::GenISA_floatatomicraw:
118118
case GenISAIntrinsic::GenISA_icmpxchgatomicraw:
119119
case GenISAIntrinsic::GenISA_fcmpxchgatomicraw:
120-
case GenISAIntrinsic::GenISA_simdBlockRead:
120+
case GenISAIntrinsic::GenISA_simdBlockRead:
121121
pBuffer = intr->getOperand(0);
122122
break;
123123
case GenISAIntrinsic::GenISA_intatomicrawA64:
@@ -267,19 +267,19 @@ void PromoteResourceToDirectAS::PromoteSamplerTextureToDirectAS(GenIntrinsicInst
267267
BufferAccessType accTy;
268268
bool canPromote = false;
269269
Value* arrayIndex = nullptr;
270-
270+
271271
std::vector<Value*> instList;
272272
Value* srcPtr = IGC::TracePointerSource(resourcePtr, false, true, instList);
273-
273+
274274
if (srcPtr)
275275
{
276276
if (auto alloca = llvm::dyn_cast<AllocaInst>(srcPtr))
277277
{
278278
arrayIndex = FindArrayIndex(instList, builder);
279279
if (arrayIndex != nullptr)
280280
{
281-
// TODO: We could read igc.read_only_array metadata attached to alloca.
282-
// If not -1, it should contain base index of this array. In this case,
281+
// TODO: We could read igc.read_only_array metadata attached to alloca.
282+
// If not -1, it should contain base index of this array. In this case,
283283
// FindArrayBaseArg would not be needed.
284284

285285
// Find input argument for the first element in this array.
@@ -289,7 +289,7 @@ void PromoteResourceToDirectAS::PromoteSamplerTextureToDirectAS(GenIntrinsicInst
289289
}
290290

291291
if (srcPtr)
292-
{
292+
{
293293
// Trace the resource pointer.
294294
// If we can find it, we can promote the indirect access to direct access
295295
// by encoding the BTI as a direct addrspace
@@ -308,7 +308,7 @@ void PromoteResourceToDirectAS::PromoteSamplerTextureToDirectAS(GenIntrinsicInst
308308
{
309309
assert(m_pCodeGenContext->type == ShaderType::OPENCL_SHADER);
310310
ModuleMetaData *modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData();
311-
if (modMD->FuncMD.find(function) != modMD->FuncMD.end())
311+
if (modMD->FuncMD.find(function) != modMD->FuncMD.end())
312312
{
313313
FunctionMetaData *funcMD = &modMD->FuncMD[function];
314314
ResourceAllocMD *resAllocMD = &funcMD->resAllocMD;
@@ -347,7 +347,7 @@ void PromoteResourceToDirectAS::PromoteSamplerTextureToDirectAS(GenIntrinsicInst
347347

348348
addrSpace = IGC::EncodeAS4GFXResource(*bufferId, bufTy, 0);
349349
PointerType* newptrType = PointerType::get(resourcePtr->getType()->getPointerElementType(), addrSpace);
350-
350+
351351
Value* mutePtr = nullptr;
352352
if (llvm::isa<llvm::ConstantInt>(bufferId))
353353
{
@@ -645,7 +645,7 @@ void PromoteResourceToDirectAS::PromoteBufferToDirectAS(Instruction* inst, Value
645645
PointerType *ptrType = PointerType::get(pBufferType, directAS);
646646
pBuffer = builder.CreateIntToPtr(offsetVal, ptrType);
647647

648-
unsigned alignment = (unsigned)llvm::cast<llvm::ConstantInt>(pIntr->getOperand(3))->getZExtValue();
648+
unsigned alignment = pBufferType->getScalarSizeInBits() / 8;
649649

650650
// Promote storeraw back to store
651651
Value* storeVal = pIntr->getOperand(2);
@@ -761,7 +761,7 @@ void PromoteResourceToDirectAS::GetAccessInstToSrcPointerMap(Instruction* inst,
761761
}
762762
else
763763
return;
764-
}
764+
}
765765

766766
Value* srcPtr = IGC::TracePointerSource(resourcePtr);
767767

IGC/GenISAIntrinsics/GenIntrinsicInst.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,6 @@ class StoreRawIntrinsic : public GenIntrinsicInst {
513513
static inline bool classof(const Value *V) {
514514
return isa<GenIntrinsicInst>(V) && classof(cast<GenIntrinsicInst>(V));
515515
}
516-
inline Value* AlignmentValue() const {
517-
return getOperand(3);
518-
}
519516
inline Value* getOffsetValue() const
520517
{
521518
return getOperand(1);
@@ -527,11 +524,6 @@ class StoreRawIntrinsic : public GenIntrinsicInst {
527524
inline void setOffsetValue(Value* V) {
528525
setOperand(1, V);
529526
}
530-
inline void setAlignment(unsigned int alignment)
531-
{
532-
Value* newAlignment = ConstantInt::get(getOperand(3)->getType(), alignment);
533-
setOperand(3, newAlignment);
534-
}
535527
};
536528

537529
class AtomicRawIntrinsic : public GenIntrinsicInst {

IGC/GenISAIntrinsics/Intrinsic_definitions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787
"GenISA_typedwrite": ["void",["anyptr","int","int","int","int","float","float","float","float"],"None"],
8888
"GenISA_ldraw_indexed": ["any:float",["anyptr","int", "int"],"ReadArgMem"],
8989
"GenISA_ldrawvector_indexed": ["anyvector",["anyptr","int", "int"],"ReadArgMem"],
90-
"GenISA_storeraw_indexed": ["void",["anyptr","int","any:float", "int"],"None"],
91-
"GenISA_storerawvector_indexed": ["void",["anyptr","int","anyvector", "int"],"None"],
90+
"GenISA_storeraw_indexed": ["void",["anyptr","int","any:float"],"None"],
91+
"GenISA_storerawvector_indexed": ["void",["anyptr","int","anyvector"],"None"],
9292
"GenISA_intatomicraw": ["anyint",["anyptr","int",0,"int"],"ReadWriteArgMem"],
9393
"GenISA_floatatomicraw": ["anyfloat",["anyptr","int",0,"int"],"ReadWriteArgMem"],
9494
"GenISA_intatomicrawA64": ["anyint",["anyptr","anyptr",0,"int"],"ReadWriteArgMem"],

0 commit comments

Comments
 (0)