search for: getnumelements

Displaying 20 results from an estimated 70 matches for "getnumelements".

2020 May 05
2
[Update][RFC] Refactor class hierarchy of VectorType in the IR
Nicolai, My plan is to remove getNumElements() as soon as possible. Hopefully within the next few weeks. I just made a patch on my machine that marks it deprecated, and it generates a ton of warnings. Given that some build bots build with -Werror, I don't think we can mark it deprecated unless all the usages are first removed. It occu...
2020 Apr 22
2
[Update][RFC] Refactor class hierarchy of VectorType in the IR
...r. This overload calls getElementCount() on the given vector and uses that to construct a new VectorType. This is a convenience helper for the cases where "I want a vector with the same shape as this other vector, but a different element type." Calls to VectorType::get(SomeTy, SomeVTy->getNumElements()) that try to implement this case are a very common source of bugs when SomeVTy is scalable, use of this helper will eliminate these bugs while also being more concise. Currently, VectorType still has its getNumElements() function, and this function is still buggy in all the scena...
2020 Mar 09
8
[RFC] Refactor class hierarchy of VectorType in the IR
Hi, I am helping with the effort to implement scalable vectors in the codebase in order to add support for generating SVE code in the Arm backend. I would like to propose a refactor of the Type class hierarchy in order to eliminate issues related to the misuse of SequentialType::getNumElements(). I would like to introduce a new class FixedVectorType that inherits from SequentialType and VectorType. VectorType would no longer inherit from SequentialType, instead directly inheriting from Type. After this change, it will be statically impossible to accidentally call SequentialType::getNumEl...
2020 Nov 11
1
Question about LLVM Rel10 llvm/IR/AsmWriter.cpp
Hi, See fuller extract below. I am curious about the for loop. for (unsigned i = 1, e = CA->getNumElements(); i != e; ++i) { What happens when CA->getNumElements() is zero ? Infinite loop???? Wouldn't the following be better. i.e. safer: for (unsigned i = 1; i < CA->getNumElements(); i++) { Kind Regards James At about line 1429: Type *ETy = CA->getType()->getElementType();...
2020 May 21
3
[RFC] Refactor class hierarchy of VectorType in the IR
...the VectorType type semantically repurposed out from under them. The documented semantics of VectorType prior to my RFC were that it is a generalization of all vector types. The VectorType contains an ElementCount, which is a pair of (bool, unsigned). If the bool is true, then the return value of getNumElements() is the minimum number of vector elements. If the bool is false, then it is the actual number of elements. My RFC has not changed these semantics. It will eventually delete a function that has been pervasively misused throughout the codebase, but the semantics remain the same. You are proposing a...
2012 Jun 03
1
[LLVMdev] Constant::getAllOnesValue(): expected behaviour or bug?
...receiving a "i32*" argument, it was returning with some big integer vector, such as <12113216 x i32>. When you call this method passing a PointerType, the following code is executed: 00152 VectorType *VTy = cast<VectorType>(Ty);00153 return ConstantVector::getSplat(VTy->getNumElements(),00154 getAllOnesValue(VTy->getElementType() When VTy->getNumElements() is called, it returns the value of the instance variable NumElementspresent in VectorType objects, but we passed in a PointerType (SequentialType), which doesn't havethis variable bu...
2009 Apr 01
2
[LLVMdev] Shuffle combine
...e, which was changed a few months ago to allow an arbitrarily-sized mask. This would be a bug all throughout this function (which generally assumes this is still the case), if the function didn't do the following check early: unsigned VWidth = cast<VectorType>(SVI.getType())->getNumElements(); if (VWidth != cast<VectorType>(LHS->getType())->getNumElements()) return 0; In other words, if the mask size is not equal to the number of elements in the vectors, it skips this transformation. Because the LHS is a shufflevector in the part of the code you are ment...
2009 Apr 01
0
[LLVMdev] Shuffle combine
..., which was changed a few months ago to allow an arbitrarily- sized mask. This would be a bug all throughout this function (which generally assumes this is still the case), if the function didn't do the following check early: unsigned VWidth = cast<VectorType>(SVI.getType())->getNumElements(); if (VWidth != cast<VectorType>(LHS->getType())->getNumElements()) return 0; In other words, if the mask size is not equal to the number of elements in the vectors, it skips this transformation. Because the LHS is a shufflevector in the part of the code you are mentioni...
2013 Nov 02
4
[LLVMdev] get function local debug info?
...o populate the data? My related snippet of code is like the following: NamedMDNode *M_Nodes = M.getNamedMetadata("llvm.dbg.cu"); for (unsigned i = 0, e = M_Nodes->getNumOperands(); i != e; ++i) { DIArray SPs = CU.getSubprograms(); for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++ i) { DISubprogram SP(SPs.getElement(i)); DIArray Vars = SP.getVariables(); for (unsigned i2 = 0, e2 = Vars.getNumElements(); i2 != e2; ++i2) { DIVariable DV(Vars.getElement(i)); DV.print(errs()); errs() << " : "; DV.getT...
2020 May 22
3
[RFC] Refactor class hierarchy of VectorType in the IR
...last several months, those of us working on the scalable vectors feature have been examining the codebase, identifying places where llvm::VectorType is used incorrectly, and fixing them. The fact is that there are many places where VectorType is correctly taken to be the generic “any vector” type. getNumElements may be being called, but it’s being called in accordance with the previously documented semantics. There are many places where it isn’t as well, and many people add new usages that are incorrect. This puts us in an unfortunate situation: if we were to take your proposal and have VectorType be t...
2009 Apr 01
2
[LLVMdev] Shuffle combine
Hi all, I'm having some trouble understanding the following lines in InstructionCombining.cpp, which possibly contain a bug: if (Mask[i] >= 2*e) NewMask.push_back(2*e); else NewMask.push_back(LHSMask[Mask[i]]); When Mask[i] is bigger than the size of LHSMask it reads out of bounds on that last line. I believe the first line is there to try to prevent that but then it
2013 Oct 02
2
[LLVMdev] [CLang] Comparing vector types - invalid error and proposed fix
...ng change in my copy (clang-3.3) that I think is a correct and valid change: File: tools/clang/lib/Sema/SemaChecking.cpp Function: Sema::GetSignedVectorType() Replace the fragment: if (TypeSize == Context.getTypeSize(Context.CharTy)) return Context.getExtVectorType(Context.CharTy, VTy->getNumElements()); ^^^^^^ with: if (TypeSize == Context.getTypeSize(Context.CharTy)) return Context.getExtVectorType(Context.SignedCharTy, VTy->getNumElements()); ^^^^^^^^^^^^ I would like to propose this as a fix for a...
2009 Apr 02
2
[LLVMdev] Shuffle combine
...e, which was changed a few months ago to allow an arbitrarily-sized mask. This would be a bug all throughout this function (which generally assumes this is still the case), if the function didn't do the following check early: unsigned VWidth = cast<VectorType>(SVI.getType())->getNumElements(); if (VWidth != cast<VectorType>(LHS->getType())->getNumElements()) return 0; In other words, if the mask size is not equal to the number of elements in the vectors, it skips this transformation. Because the LHS is a shufflevector in the part of the code you are ment...
2009 Apr 01
0
[LLVMdev] Shuffle combine
...ago to allow an > arbitrarily-sized mask. > > This would be a bug all throughout this function (which generally > assumes this is still the case), if the function didn't do the > following check early: > > unsigned VWidth = cast<VectorType>(SVI.getType())->getNumElements(); > > if (VWidth != cast<VectorType>(LHS->getType())->getNumElements()) > return 0; > > In other words, if the mask size is not equal to the number of > elements in the vectors, it skips this transformation. > > Because the LHS is a shufflevector in the...
2009 Apr 03
0
[LLVMdev] Shuffle combine
...ago to allow an > arbitrarily-sized mask. > > This would be a bug all throughout this function (which generally > assumes this is still the case), if the function didn't do the > following check early: > > unsigned VWidth = cast<VectorType>(SVI.getType())->getNumElements(); > > if (VWidth != cast<VectorType>(LHS->getType())->getNumElements()) > return 0; > > In other words, if the mask size is not equal to the number of > elements in the vectors, it skips this transformation. > > Because the LHS is a shufflevector in the...
2013 Oct 02
0
[LLVMdev] [CLang] Comparing vector types - invalid error and proposed fix
...correct and > valid change: > > File: tools/clang/lib/Sema/SemaChecking.cpp > Function: Sema::GetSignedVectorType() > > Replace the fragment: > > if (TypeSize == Context.getTypeSize(Context.CharTy)) > return Context.getExtVectorType(Context.CharTy, > VTy->getNumElements()); > ^^^^^^ > with: > if (TypeSize == Context.getTypeSize(Context.CharTy)) > return Context.getExtVectorType(Context.SignedCharTy, > VTy->getNumElements()); > ^^^^^^^^^^^^ > > I wo...
2013 Nov 03
0
[LLVMdev] get function local debug info?
...t; My related snippet of code is like the following: > > NamedMDNode *M_Nodes = M.getNamedMetadata("llvm.dbg.cu"); > for (unsigned i = 0, e = M_Nodes->getNumOperands(); i != e; ++i) { > DIArray SPs = CU.getSubprograms(); > for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++ i) { > DISubprogram SP(SPs.getElement(i)); > DIArray Vars = SP.getVariables(); > for (unsigned i2 = 0, e2 = Vars.getNumElements(); i2 != e2; ++i2) { > DIVariable DV(Vars.getElement(i)); > DV.print(errs()); errs() << &quo...
2011 Jan 12
1
[LLVMdev] newbi to llvm - how to get array size
...e from llvm to a non-deterministic language and want to include array bounds check in it. The array size gets printed as part of the type of the value <pty> <result> = getelementptr inbounds <pty>* <ptrval> (ty idx) I am wrongly expecting I.getOperand(0)->getType()->getNumElements() to give me the array size (after casting ptrval to array type) I am not getting the array size, I am getting a value of zero. Can someone point out to me how to get array size (number of elements in the array) from the type object. What about multi-dimension arrays too. Thanks. Surinder Kuma...
2004 Dec 03
1
[Fwd: [LLVMdev] GetElementPtr for packed types and VS build]
...r/cvs/llvm/llvm/lib/Target/TargetData.cpp,v > retrieving revision 1.53 > diff -u -r1.53 TargetData.cpp > --- lib/Target/TargetData.cpp 2 Nov 2004 22:18:18 -0000 1.53 > +++ lib/Target/TargetData.cpp 26 Nov 2004 09:46:45 -0000 > @@ -175,6 +175,13 @@ > Size = AlignedSize*ATy->getNumElements(); > return; > } > + case Type::PackedTyID: { > + const PackedType *PTy = cast<PackedType>(Ty); > + getTypeInfo(PTy->getElementType(), TD, Size, Alignment); > + unsigned AlignedSize = (Size + Alignment - 1)/Alignment*Alignment; > + Size = AlignedSi...
2020 May 21
5
[RFC] Refactor class hierarchy of VectorType in the IR
...a-mole with people adding new broken code after the fact. The previous API was very easy to misuse, so I don’t blame those people. > Are you actually auditing and testing them all to work for scalable vector types, or are you just fixing the obvious compile failures? Everywhere that VectorType::getNumElements() is being called, we are either changing the code to cast to FixedVectorType, or we are updating the code to handle scalable vectors correctly. If the call site does not have test coverage with scalable vectors, this test coverage is being added. Even for obviously correct transformations such as...