summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPawel Wodnicki <pawel@32bitmicro.com>2012-11-21 19:01:53 +0000
committerPawel Wodnicki <pawel@32bitmicro.com>2012-11-21 19:01:53 +0000
commit07d7748544abaaf97123233804a194478ed020b3 (patch)
tree03f936edbb07aad478f391f460fe3602da8044e4 /lib
parentb30ce3e484f1e7f37a709e6fa7a91712a3d85e97 (diff)
downloadllvm-07d7748544abaaf97123233804a194478ed020b3.tar.gz
llvm-07d7748544abaaf97123233804a194478ed020b3.tar.bz2
llvm-07d7748544abaaf97123233804a194478ed020b3.tar.xz
Merging r168181: into 3.2 release branch.
Fix PR14361: wrong simplification of A+B==B+A. You may think that the old logic replaced by this patch is equivalent to the new logic, but you'd be wrong, and that's exactly where the bug was. There's a similar bug in instsimplify which manifests itself as instsimplify failing to simplify this, rather than doing it wrong, see next commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_32@168447 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCompares.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 8cb4a59cba..e223a049f0 100644
--- a/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -2356,8 +2356,20 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
// Try not to increase register pressure.
BO0->hasOneUse() && BO1->hasOneUse()) {
// Determine Y and Z in the form icmp (X+Y), (X+Z).
- Value *Y = (A == C || A == D) ? B : A;
- Value *Z = (C == A || C == B) ? D : C;
+ Value *Y, *Z;
+ if (A == C) {
+ Y = B;
+ Z = D;
+ } else if (A == D) {
+ Y = B;
+ Z = C;
+ } else if (B == C) {
+ Y = A;
+ Z = D;
+ } else if (B == D) {
+ Y = A;
+ Z = C;
+ }
return new ICmpInst(Pred, Y, Z);
}