diff options
author | Pawel Wodnicki <pawel@32bitmicro.com> | 2012-11-26 16:52:27 +0000 |
---|---|---|
committer | Pawel Wodnicki <pawel@32bitmicro.com> | 2012-11-26 16:52:27 +0000 |
commit | bc69dc1d880792c0c2bbea189c3dbb2c39505391 (patch) | |
tree | a46f0619346bac6516b4b5fe547d46fc48cd0bdd | |
parent | 077cee586eda8b0edcca1ff07e823104eff718e7 (diff) | |
download | llvm-bc69dc1d880792c0c2bbea189c3dbb2c39505391.tar.gz llvm-bc69dc1d880792c0c2bbea189c3dbb2c39505391.tar.bz2 llvm-bc69dc1d880792c0c2bbea189c3dbb2c39505391.tar.xz |
Merging r168196: into the 3.2 release branch.
Make this easier to understand, as suggested by Chandler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_32@168594 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/InstructionSimplify.cpp | 7 | ||||
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineCompares.cpp | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index c24c18f807..a76e5ad1b8 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -2067,15 +2067,20 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, // Determine Y and Z in the form icmp (X+Y), (X+Z). Value *Y, *Z; if (A == C) { + // C + B == C + D -> B == D Y = B; Z = D; } else if (A == D) { + // D + B == C + D -> B == C Y = B; Z = C; } else if (B == C) { + // A + C == C + D -> A == D Y = A; Z = D; - } else if (B == D) { + } else { + assert(B == D); + // A + D == C + D -> A == C Y = A; Z = C; } diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index e223a049f0..7c3f8fe15d 100644 --- a/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2358,15 +2358,20 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { // Determine Y and Z in the form icmp (X+Y), (X+Z). Value *Y, *Z; if (A == C) { + // C + B == C + D -> B == D Y = B; Z = D; } else if (A == D) { + // D + B == C + D -> B == C Y = B; Z = C; } else if (B == C) { + // A + C == C + D -> A == D Y = A; Z = D; - } else if (B == D) { + } else { + assert(B == D); + // A + D == C + D -> A == C Y = A; Z = C; } |