mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[ValueTracking] Fix one s/dyn_cast/dyn_cast_or_null/
Handle if Constant::getAggregateElement() returns nullptr in canCreateUndefOrPoison(). Differential Revision: https://reviews.llvm.org/D94494
This commit is contained in:
parent
126c3ccc68
commit
8e1b636cfa
@ -4737,7 +4737,7 @@ static bool canCreateUndefOrPoison(const Operator *Op, bool PoisonOnly) {
|
||||
ShiftAmounts.push_back(C);
|
||||
|
||||
bool Safe = llvm::all_of(ShiftAmounts, [](Constant *C) {
|
||||
auto *CI = dyn_cast<ConstantInt>(C);
|
||||
auto *CI = dyn_cast_or_null<ConstantInt>(C);
|
||||
return CI && CI->getValue().ult(C->getType()->getIntegerBitWidth());
|
||||
});
|
||||
return !Safe;
|
||||
|
@ -943,6 +943,7 @@ TEST_F(ValueTrackingTest, isGuaranteedNotToBeUndefOrPoison_assume) {
|
||||
|
||||
TEST(ValueTracking, canCreatePoisonOrUndef) {
|
||||
std::string AsmHead =
|
||||
"@s = external dso_local global i32, align 1\n"
|
||||
"declare i32 @g(i32)\n"
|
||||
"define void @f(i32 %x, i32 %y, float %fx, float %fy, i1 %cond, "
|
||||
"<4 x i32> %vx, <4 x i32> %vx2, <vscale x 4 x i32> %svx, i8* %p) {\n";
|
||||
@ -1001,7 +1002,11 @@ TEST(ValueTracking, canCreatePoisonOrUndef) {
|
||||
{{true, false}, "call i32 @g(i32 %x)"},
|
||||
{{false, false}, "call noundef i32 @g(i32 %x)"},
|
||||
{{true, false}, "fcmp nnan oeq float %fx, %fy"},
|
||||
{{false, false}, "fcmp oeq float %fx, %fy"}};
|
||||
{{false, false}, "fcmp oeq float %fx, %fy"},
|
||||
{{true, false},
|
||||
"ashr <4 x i32> %vx, select (i1 icmp sgt (i32 ptrtoint (i32* @s to "
|
||||
"i32), i32 1), <4 x i32> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 "
|
||||
"2, i32 3>)"}};
|
||||
|
||||
std::string AssemblyStr = AsmHead;
|
||||
for (auto &Itm : Data)
|
||||
|
Loading…
Reference in New Issue
Block a user