[PatternMatch] allow undef elements when matching a vector zero
authorSanjay Patel <spatel@rotateright.com>
Sun, 22 Apr 2018 17:07:44 +0000 (17:07 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sun, 22 Apr 2018 17:07:44 +0000 (17:07 +0000)
commit30be665e82989243f5a9b4c71ec1805c59b376ec
treee1865da5b1e432b58a85d56dd8d296c3dd5f0e1d
parentc7f9b183c2551dc478ff2b55b287e900dc8719f8
[PatternMatch] allow undef elements when matching a vector zero

This is the last step in getting constant pattern matchers to allow
undef elements in constant vectors.

I'm adding a dedicated m_ZeroInt() function and building m_Zero() from
that. In most cases, calling code can be updated to use m_ZeroInt()
directly when there's no need to match pointers, but I'm leaving that
efficiency optimization as a follow-up step because it's not always
clear when that's ok.

There are just enough icmp folds in InstSimplify that can be used for
integer or pointer types, that we probably still want a generic m_Zero()
for those cases. Otherwise, we could eliminate it (and possibly add a
m_NullPtr() as an alias for isa<ConstantPointerNull>()).

We're conservatively returning a full zero vector (zeroinitializer) in
InstSimplify/InstCombine on some of these folds (see diffs in InstSimplify),
but I'm not sure if that's actually necessary in all cases. We may be
able to propagate an undef lane instead. One test where this happens is
marked with 'TODO'.

llvm-svn: 330550
15 files changed:
llvm/include/llvm/IR/PatternMatch.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/X86/x86-vector-shifts.ll
llvm/test/Transforms/InstCombine/cast-int-icmp-eq-0.ll
llvm/test/Transforms/InstCombine/cast-unsigned-icmp-eqcmp-0.ll
llvm/test/Transforms/InstCombine/min-positive.ll
llvm/test/Transforms/InstCombine/select-of-bittest.ll
llvm/test/Transforms/InstSimplify/AndOrXor.ll
llvm/test/Transforms/InstSimplify/cast-unsigned-icmp-cmp-0.ll
llvm/test/Transforms/InstSimplify/div.ll
llvm/test/Transforms/InstSimplify/mul.ll
llvm/test/Transforms/InstSimplify/negate.ll
llvm/test/Transforms/InstSimplify/rem.ll
llvm/test/Transforms/InstSimplify/shift.ll