Make this easier to understand, as suggested by Chandler.
authorDuncan Sands <baldrick@free.fr>
Fri, 16 Nov 2012 20:53:08 +0000 (20:53 +0000)
committerDuncan Sands <baldrick@free.fr>
Fri, 16 Nov 2012 20:53:08 +0000 (20:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168196 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/InstructionSimplify.cpp
lib/Transforms/InstCombine/InstCombineCompares.cpp

index c24c18f8072856e1bbdb1ed17bd0abc3be2de33c..a76e5ad1b8f88621c63a590687251bd7b7b4a0ec 100644 (file)
@@ -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;
       }
index e223a049f0b0606a285b5d5d7c4f044a569aef6b..7c3f8fe15d307824d9a069bd86bc44fec07c09ac 100644 (file)
@@ -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;
       }