Disable loop unswitching for some patterns containing equality comparison with undef.
authorWei Mi <wmi@google.com>
Tue, 25 Jul 2017 23:37:17 +0000 (23:37 +0000)
committerWei Mi <wmi@google.com>
Tue, 25 Jul 2017 23:37:17 +0000 (23:37 +0000)
commitfc0e245464bc29d0025e02471d5f1ae6b74ac19c
treebe02d7872fe5f0220588438031338f94bcb8eb71
parent8f94a2350538f7fa7504f2f963760230dd197cab
Disable loop unswitching for some patterns containing equality comparison with undef.

This is a workaround for the bug described in PR31652 and
http://lists.llvm.org/pipermail/llvm-dev/2017-July/115497.html. The temporary
solution is to add a function EqualityPropUnSafe. In EqualityPropUnSafe, for
some simple patterns we can know the equality comparison may contains undef,
so we regard such comparison as unsafe and will not do loop-unswitching for
them. We also need to disable the select simplification when one of select
operand is undef and its result feeds into equality comparison.

The patch cannot clear the safety issue caused by the bug, but it can suppress
the issue from happening to some extent.

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

llvm-svn: 309059
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
llvm/test/Transforms/LoopUnswitch/unswitch-equality-undef.ll [new file with mode: 0644]