diff options
author | Nadav Rotem <nadav.rotem@intel.com> | 2011-02-15 07:13:48 +0000 |
---|---|---|
committer | Nadav Rotem <nadav.rotem@intel.com> | 2011-02-15 07:13:48 +0000 |
commit | d9e087bbc31f71a91ce5497f41e50de439805220 (patch) | |
tree | 4894c76dd9d1065d9e5743e02131842d1ac4ec22 /lib | |
parent | 326d976eb2b03d1f2b7537d7b90dff264fd84378 (diff) | |
download | llvm-d9e087bbc31f71a91ce5497f41e50de439805220.tar.gz llvm-d9e087bbc31f71a91ce5497f41e50de439805220.tar.bz2 llvm-d9e087bbc31f71a91ce5497f41e50de439805220.tar.xz |
Fix 9216 - Endless loop in InstCombine pass.
The pattern "A&(A^B) -> A & ~B" recreated itself because ~B is
actually a xor -1.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index d9380be4c6..b6b6b84d96 100644 --- a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -1140,7 +1140,11 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { cast<BinaryOperator>(Op1)->swapOperands(); std::swap(A, B); } - if (A == Op0) // A&(A^B) -> A & ~B + // Notice that the patten (A&(~B)) is actually (A&(-1^B)), so if + // A is originally -1 (or a vector of -1 and undefs), then we enter + // an endless loop. By checking that A is non-constant we ensure that + // we will never get to the loop. + if (A == Op0 && !isa<Constant>(A)) // A&(A^B) -> A & ~B return BinaryOperator::CreateAnd(A, Builder->CreateNot(B, "tmp")); } |