// Evaluate the BinOp on the incoming phi values.
Value *CommonValue = 0;
for (unsigned i = 0, e = PI->getNumIncomingValues(); i != e; ++i) {
+ Value *Incoming = PI->getIncomingValue(i);
+ // If the incoming value is the phi node itself, it can be safely skipped.
+ if (Incoming == PI) continue;
Value *V = PI == LHS ?
- SimplifyBinOp(Opcode, PI->getIncomingValue(i), RHS, TD, MaxRecurse) :
- SimplifyBinOp(Opcode, LHS, PI->getIncomingValue(i), TD, MaxRecurse);
+ SimplifyBinOp(Opcode, Incoming, RHS, TD, MaxRecurse) :
+ SimplifyBinOp(Opcode, LHS, Incoming, TD, MaxRecurse);
// If the operation failed to simplify, or simplified to a different value
// to previously, then give up.
if (!V || (CommonValue && V != CommonValue))
// Evaluate the BinOp on the incoming phi values.
Value *CommonValue = 0;
for (unsigned i = 0, e = PI->getNumIncomingValues(); i != e; ++i) {
- Value *V = SimplifyCmpInst(Pred, PI->getIncomingValue(i), RHS, TD,
- MaxRecurse);
+ Value *Incoming = PI->getIncomingValue(i);
+ // If the incoming value is the phi node itself, it can be safely skipped.
+ if (Incoming == PI) continue;
+ Value *V = SimplifyCmpInst(Pred, Incoming, RHS, TD, MaxRecurse);
// If the operation failed to simplify, or simplified to a different value
// to previously, then give up.
if (!V || (CommonValue && V != CommonValue))
; CHECK: @test20
; CHECK: ret i1 false
}
+
+define i1 @test21(i1 %c1, i1 %c2) {
+ %a = alloca i32
+ %b = alloca i32
+ %c = alloca i32
+ br i1 %c1, label %true, label %false
+true:
+ br label %loop
+false:
+ br label %loop
+loop:
+ %p = phi i32* [ %a, %true ], [ %b, %false ], [ %p, %loop ]
+ %r = icmp eq i32* %p, %c
+ br i1 %c2, label %ret, label %loop
+ret:
+ ret i1 %r
+; CHECK: @test21
+; CHECK: ret i1 false
+}