[InstSimplify] allow undef element match in vector select condition value
authorSanjay Patel <spatel@rotateright.com>
Tue, 25 May 2021 18:18:07 +0000 (14:18 -0400)
committerSanjay Patel <spatel@rotateright.com>
Tue, 25 May 2021 18:25:34 +0000 (14:25 -0400)
commitca7eaa0a54938bfe9aeed7ebc64202f0b6f2ce0d
tree80dc2aa9702b654df5d6b0509abf3c7576eb582b
parent31d1ae79752da75503a4f1deb3ef2fd0b7868682
[InstSimplify] allow undef element match in vector select condition value

The semantics of select with undefined/poison condition
are not explicitly stated in the LangRef, but this matches
comments in the code and Alive2 appears to concur:
https://alive2.llvm.org/ce/z/KXytmd

We can find this pattern after demanded elements transforms.

As noted in D101191, fuzzers are finding infinite loops because
we may not account for this pattern in other passes.
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstCombine/select.ll
llvm/test/Transforms/InstSimplify/select-inseltpoison.ll
llvm/test/Transforms/InstSimplify/select.ll