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 | 67d67a0385a8bd5ec044e94d09b5229559f840b4 (patch) | |
tree | 0d5c9fad6066dd1df5e435ed69897169f12fb0e2 /llvm/lib/Transforms | |
parent | 25849cab8bef790cf06e25fa8152f1c17321efaa (diff) | |
download | bcm5719-llvm-67d67a0385a8bd5ec044e94d09b5229559f840b4.tar.gz bcm5719-llvm-67d67a0385a8bd5ec044e94d09b5229559f840b4.zip |
Fix 9216 - Endless loop in InstCombine pass.
The pattern "A&(A^B) -> A & ~B" recreated itself because ~B is
actually a xor -1.
llvm-svn: 125557
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index d9380be4c67..b6b6b84d964 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/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")); } |