forked from OSchip/llvm-project
[AMDGPU] Pull out repeated getVecSize() calls. NFC.
This is guaranteed to be evaluated so we can avoid repeated calls. Helps the static analyzer as it couldn't recognise that each getVecSize() would return the same value.
This commit is contained in:
parent
8b58494cea
commit
8de7297374
|
@ -1593,8 +1593,9 @@ bool AMDGPULibCalls::evaluateCall(CallInst *aCI, const FuncInfo &FInfo) {
|
|||
|
||||
// max vector size is 16, and sincos will generate two results.
|
||||
double DVal0[16], DVal1[16];
|
||||
int FuncVecSize = getVecSize(FInfo);
|
||||
bool hasTwoResults = (FInfo.getId() == AMDGPULibFunc::EI_SINCOS);
|
||||
if (getVecSize(FInfo) == 1) {
|
||||
if (FuncVecSize == 1) {
|
||||
if (!evaluateScalarMathFunc(FInfo, DVal0[0],
|
||||
DVal1[0], copr0, copr1, copr2)) {
|
||||
return false;
|
||||
|
@ -1603,7 +1604,7 @@ bool AMDGPULibCalls::evaluateCall(CallInst *aCI, const FuncInfo &FInfo) {
|
|||
ConstantDataVector *CDV0 = dyn_cast_or_null<ConstantDataVector>(copr0);
|
||||
ConstantDataVector *CDV1 = dyn_cast_or_null<ConstantDataVector>(copr1);
|
||||
ConstantDataVector *CDV2 = dyn_cast_or_null<ConstantDataVector>(copr2);
|
||||
for (int i=0; i < getVecSize(FInfo); ++i) {
|
||||
for (int i = 0; i < FuncVecSize; ++i) {
|
||||
Constant *celt0 = CDV0 ? CDV0->getElementAsConstant(i) : nullptr;
|
||||
Constant *celt1 = CDV1 ? CDV1->getElementAsConstant(i) : nullptr;
|
||||
Constant *celt2 = CDV2 ? CDV2->getElementAsConstant(i) : nullptr;
|
||||
|
@ -1616,19 +1617,19 @@ bool AMDGPULibCalls::evaluateCall(CallInst *aCI, const FuncInfo &FInfo) {
|
|||
|
||||
LLVMContext &context = CI->getParent()->getParent()->getContext();
|
||||
Constant *nval0, *nval1;
|
||||
if (getVecSize(FInfo) == 1) {
|
||||
if (FuncVecSize == 1) {
|
||||
nval0 = ConstantFP::get(CI->getType(), DVal0[0]);
|
||||
if (hasTwoResults)
|
||||
nval1 = ConstantFP::get(CI->getType(), DVal1[0]);
|
||||
} else {
|
||||
if (getArgType(FInfo) == AMDGPULibFunc::F32) {
|
||||
SmallVector <float, 0> FVal0, FVal1;
|
||||
for (int i=0; i < getVecSize(FInfo); ++i)
|
||||
for (int i = 0; i < FuncVecSize; ++i)
|
||||
FVal0.push_back((float)DVal0[i]);
|
||||
ArrayRef<float> tmp0(FVal0);
|
||||
nval0 = ConstantDataVector::get(context, tmp0);
|
||||
if (hasTwoResults) {
|
||||
for (int i=0; i < getVecSize(FInfo); ++i)
|
||||
for (int i = 0; i < FuncVecSize; ++i)
|
||||
FVal1.push_back((float)DVal1[i]);
|
||||
ArrayRef<float> tmp1(FVal1);
|
||||
nval1 = ConstantDataVector::get(context, tmp1);
|
||||
|
|
Loading…
Reference in New Issue