OSDN Git Service

[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)
commite1bbe8420730ef2b5e5897ee16eca0ed8df4c213
tree03b2c21eb8b0e4c125394de7a93fbee29629cd72
parent21ad2d4248144e41b39dfcffc09fbe5538138836
[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'.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330550 91177308-0d34-0410-b5e6-96231b3b80d8
15 files changed:
include/llvm/IR/PatternMatch.h
lib/Analysis/InstructionSimplify.cpp
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
test/Transforms/InstCombine/X86/x86-vector-shifts.ll
test/Transforms/InstCombine/cast-int-icmp-eq-0.ll
test/Transforms/InstCombine/cast-unsigned-icmp-eqcmp-0.ll
test/Transforms/InstCombine/min-positive.ll
test/Transforms/InstCombine/select-of-bittest.ll
test/Transforms/InstSimplify/AndOrXor.ll
test/Transforms/InstSimplify/cast-unsigned-icmp-cmp-0.ll
test/Transforms/InstSimplify/div.ll
test/Transforms/InstSimplify/mul.ll
test/Transforms/InstSimplify/negate.ll
test/Transforms/InstSimplify/rem.ll
test/Transforms/InstSimplify/shift.ll