forked from OSchip/llvm-project
[TTI] getUserCost - Ensure a vector insert/extract index is in unsigned 32-bit range
Otherwise fallback to the generic 'unknown index' path Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29050
This commit is contained in:
parent
ed687c0211
commit
993f3c61b3
|
@ -1068,8 +1068,10 @@ public:
|
|||
auto *IE = dyn_cast<InsertElementInst>(U);
|
||||
if (!IE)
|
||||
return TTI::TCC_Basic; // FIXME
|
||||
auto *CI = dyn_cast<ConstantInt>(IE->getOperand(2));
|
||||
unsigned Idx = CI ? CI->getZExtValue() : -1;
|
||||
unsigned Idx = -1;
|
||||
if (auto *CI = dyn_cast<ConstantInt>(IE->getOperand(2)))
|
||||
if (CI->getValue().getActiveBits() <= 32)
|
||||
Idx = CI->getZExtValue();
|
||||
return TargetTTI->getVectorInstrCost(Opcode, Ty, Idx);
|
||||
}
|
||||
case Instruction::ShuffleVector: {
|
||||
|
@ -1132,17 +1134,15 @@ public:
|
|||
Shuffle->getShuffleMask(), 0, nullptr);
|
||||
}
|
||||
case Instruction::ExtractElement: {
|
||||
unsigned Idx = -1;
|
||||
auto *EEI = dyn_cast<ExtractElementInst>(U);
|
||||
if (!EEI)
|
||||
return TTI::TCC_Basic; // FIXME
|
||||
|
||||
auto *CI = dyn_cast<ConstantInt>(EEI->getOperand(1));
|
||||
if (CI)
|
||||
unsigned Idx = -1;
|
||||
if (auto *CI = dyn_cast<ConstantInt>(EEI->getOperand(1)))
|
||||
if (CI->getValue().getActiveBits() <= 32)
|
||||
Idx = CI->getZExtValue();
|
||||
|
||||
return TargetTTI->getVectorInstrCost(Opcode, U->getOperand(0)->getType(),
|
||||
Idx);
|
||||
Type *DstTy = U->getOperand(0)->getType();
|
||||
return TargetTTI->getVectorInstrCost(Opcode, DstTy, Idx);
|
||||
}
|
||||
}
|
||||
// By default, just classify everything as 'basic'.
|
||||
|
|
|
@ -73,3 +73,15 @@ define void @test4() noreturn nounwind {
|
|||
store i32 undef, i32* @g_47, align 4
|
||||
br label %1
|
||||
}
|
||||
|
||||
; OSS-Fuzz #29050
|
||||
; https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29050
|
||||
define <2 x i177> @ossfuzz_29050(<2 x i177> %X) {
|
||||
bb:
|
||||
br label %BB
|
||||
BB:
|
||||
%I3 = insertelement <2 x i177> undef, i177 95780971304118053647396689196894323976171195136475135, i177 95780971304118053647396689196894323976171195136475135
|
||||
br i1 true, label %BB, label %BB1
|
||||
BB1:
|
||||
ret <2 x i177> %I3
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue