Skip to content

Commit bc69dc1

Browse files
committed
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
1 parent 077cee5 commit bc69dc1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/Analysis/InstructionSimplify.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2067,15 +2067,20 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
20672067
// Determine Y and Z in the form icmp (X+Y), (X+Z).
20682068
Value *Y, *Z;
20692069
if (A == C) {
2070+
// C + B == C + D -> B == D
20702071
Y = B;
20712072
Z = D;
20722073
} else if (A == D) {
2074+
// D + B == C + D -> B == C
20732075
Y = B;
20742076
Z = C;
20752077
} else if (B == C) {
2078+
// A + C == C + D -> A == D
20762079
Y = A;
20772080
Z = D;
2078-
} else if (B == D) {
2081+
} else {
2082+
assert(B == D);
2083+
// A + D == C + D -> A == C
20792084
Y = A;
20802085
Z = C;
20812086
}

lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2358,15 +2358,20 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
23582358
// Determine Y and Z in the form icmp (X+Y), (X+Z).
23592359
Value *Y, *Z;
23602360
if (A == C) {
2361+
// C + B == C + D -> B == D
23612362
Y = B;
23622363
Z = D;
23632364
} else if (A == D) {
2365+
// D + B == C + D -> B == C
23642366
Y = B;
23652367
Z = C;
23662368
} else if (B == C) {
2369+
// A + C == C + D -> A == D
23672370
Y = A;
23682371
Z = D;
2369-
} else if (B == D) {
2372+
} else {
2373+
assert(B == D);
2374+
// A + D == C + D -> A == C
23702375
Y = A;
23712376
Z = C;
23722377
}

0 commit comments

Comments
 (0)