[InstCombine] Use m_Zero instead of isNullValue() when checking if a GEP index is...
authorCraig Topper <craig.topper@intel.com>
Thu, 26 Sep 2019 17:20:50 +0000 (17:20 +0000)
committerCraig Topper <craig.topper@intel.com>
Thu, 26 Sep 2019 17:20:50 +0000 (17:20 +0000)
commit46721bb7f5216c7b528496b6b0a695f61c0fb544
treed3dc24b7ba63a0c60204585f22176133575a4908
parentadc183018715ee979c2e2532b9669f480b6bf37c
[InstCombine] Use m_Zero instead of isNullValue() when checking if a GEP index is all zeroes to prevent an infinite loop.

The test case here previously infinite looped. Only one element from the GEP is used so SimplifyDemandedVectorElts would replace the other lanes in each index with undef leading to the first index being <0, undef, undef, undef>. But there's a GEP transform that tries to replace an index into a 0 sized type with a zero index. But the zero index check only works on ConstantInt 0 or ConstantAggregateZero so it would turn the index back to zeroinitializer. Resulting in a loop.

The fix is to use m_Zero() to allow a vector of zeroes and undefs.

Differential Revision: https://reviews.llvm.org/D67977

llvm-svn: 373000
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/vec_demanded_elts.ll