1; RUN: llc < %s | FileCheck %s 2; 3; PR11431: handle a phi operand that is replaced by a postinc user. 4; LSR first expands %t3 to %t2 in %phi 5; LSR then expands %t2 in %phi into two decrements, one on each loop exit. 6 7target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-f128:128:128-n8:16:32:64" 8target triple = "x86_64-unknown-linux-gnu" 9 10declare i1 @check() nounwind 11 12; Check that LSR did something close to the behavior at the time of the bug. 13; CHECK: @sqlite3DropTriggerPtr 14; CHECK: incq %r{{[a-d]}}x 15; CHECK: jne 16; CHECK: decq %r{{[a-d]}}x 17; CHECK: ret 18define i64 @sqlite3DropTriggerPtr() nounwind { 19bb: 20 %cmp = call zeroext i1 @check() 21 br label %bb1 22 23bb1: ; preds = %bb4, %bb 24 %t0 = phi i64 [ 0, %bb ], [ %t3, %bb4 ] 25 %t2 = phi i64 [ 1, %bb ], [ %t5, %bb4 ] 26 %t3 = add nsw i64 %t0, 1 27 br i1 %cmp, label %bb4, label %bb8 28 29bb4: ; preds = %bb1 30 %t5 = add nsw i64 %t2, 1 31 br i1 %cmp, label %bb1, label %bb8 32 33bb8: ; preds = %bb8, %bb4 34 %phi = phi i64 [ %t3, %bb1 ], [ %t2, %bb4 ] 35 ret i64 %phi 36} 37