@@ -41,7 +41,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4141using namespace llvm ;
4242using 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//
9292namespace
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.
457457void 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 {
0 commit comments