Trivial change of a dyn_cast to dyn_cast_or_null in ValueTracking.
The issue was found with attached input bbi-51646.ll If necessary it could be added as a regression test but then the question is where (i.e. should it piggyback on some other file).
Constant::getAggregateElement() at line 4733 may return nullptr.
Probably just in its own file (we don't do a very good job of keeping a lot of related tests in a single file together - usually just add more files, it's not ideal but often hard to find other good groupings) - but if you're looking for related test files, try breaking the pass in some obvious way and see what tests fail - that should help you find some related tests that could be piggy backed on.
Yes, a test should be added.
ashr <4 x i16> %induction, select (i1 icmp sgt (i16 ptrtoint (i16* @c to i16), i16 1), <4 x i16> zeroinitializer, <4 x i16> <i16 ptrtoint (i16* @c to i16), i16 ptrtoint (i16* @c to i16), i16 ptrtoint (i16* @c to i16), i16 ptrtoint (i16* @c to i16)>)
is the problematic part?
If it is non-trivial to further reduce the input, you can also add this instruction to the list at ValueTrackingTest.cpp 's TEST(ValueTracking, canCreatePoisonOrUndef).
Yes that is the problematic part. I think it makes most sense to add as a targeted unit-test for the specific function as below. Unfortunately the IR line is a bit messy but I was not able to simplify it any further. I guess it needs to be something that is considered a Constant but yet does not simplify to an "actual" Constant during import.