[PATCH] D128911: Emit table lookup from TargetLowering::expandCTTZ()
Shubham Narlawar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 8 04:49:10 PDT 2022
gsocshubham added a comment.
I am generating table at end of `TargetLowering::expandCTTZ()` as below -
// Create a table in constant data pool
std::vector<Constant *> Elt;
unsigned int RshrArr[NumBitsPerElt];
unsigned int DeBrujin = 0x077CB531U;
for (unsigned int i = 0; i < NumBitsPerElt; i++) {
unsigned int Lshr = DeBrujin << i;
unsigned int Rshr = Lshr >> 27;
RshrArr[Rshr] = i;
}
for (unsigned int i = 0; i < NumBitsPerElt; i++) {
SDValue Index = DAG.getConstant(RshrArr[i], dl, VT);
ConstantSDNode *IndexNode = dyn_cast<ConstantSDNode>(Index);
ConstantInt *temp = const_cast<ConstantInt *>(IndexNode->getConstantIntValue());
Constant *ConstantData = dyn_cast<Constant >(temp);
Elt.push_back(ConstantData);
}
ArrayRef<Constant *> Elts = Elt;
...code for indexing into above table
I will post update patch within a while.
Note - I will change RshrArr from variable length array to vector.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128911/new/
https://reviews.llvm.org/D128911
More information about the llvm-commits
mailing list