diff options
| author | Duncan Sands <baldrick@free.fr> | 2012-11-16 20:53:08 +0000 |
|---|---|---|
| committer | Duncan Sands <baldrick@free.fr> | 2012-11-16 20:53:08 +0000 |
| commit | d7d8c09b93db9818856844f926c3e1cec56ae857 (patch) | |
| tree | 37e9397ab9fddb31dedb9d95cd80c6186f88aef8 /llvm/lib | |
| parent | d680379f0bac1f5ad38db1b877826b76b6b1e888 (diff) | |
| download | bcm5719-llvm-d7d8c09b93db9818856844f926c3e1cec56ae857.tar.gz bcm5719-llvm-d7d8c09b93db9818856844f926c3e1cec56ae857.zip | |
Make this easier to understand, as suggested by Chandler.
llvm-svn: 168196
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index c24c18f8072..a76e5ad1b8f 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/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/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index e223a049f0b..7c3f8fe15d3 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/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; } |

