blob: 8053940df13f8f119cb9ba9e1f25336c3e53cbf6 [file] [log] [blame]
Andrew Trickceafa2c2011-11-30 06:07:54 +00001; RUN: llc < %s | FileCheck %s
2;
3; PR11431: handle a phi operand that is replaced by a postinc user.
Andrew Trick613c67e2011-11-30 06:26:42 +00004; LSR first expands %t3 to %t2 in %phi
5; LSR then expands %t2 in %phi into two decrements, one on each loop exit.
Andrew Trickceafa2c2011-11-30 06:07:54 +00006
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
Andrew Tricke2431c62013-05-25 03:08:10 +000014; CHECK: incq %r{{[a-d]}}x
Andrew Trick613c67e2011-11-30 06:26:42 +000015; CHECK: jne
Andrew Tricke2431c62013-05-25 03:08:10 +000016; CHECK: decq %r{{[a-d]}}x
Andrew Trickceafa2c2011-11-30 06:07:54 +000017; CHECK: ret
Andrew Trick613c67e2011-11-30 06:26:42 +000018define i64 @sqlite3DropTriggerPtr() nounwind {
19bb:
20 %cmp = call zeroext i1 @check()
21 br label %bb1
Andrew Trickceafa2c2011-11-30 06:07:54 +000022
Andrew Trick613c67e2011-11-30 06:26:42 +000023bb1: ; 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
Andrew Trickceafa2c2011-11-30 06:07:54 +000028
Andrew Trick613c67e2011-11-30 06:26:42 +000029bb4: ; preds = %bb1
30 %t5 = add nsw i64 %t2, 1
31 br i1 %cmp, label %bb1, label %bb8
Andrew Trickceafa2c2011-11-30 06:07:54 +000032
Andrew Trick613c67e2011-11-30 06:26:42 +000033bb8: ; preds = %bb8, %bb4
34 %phi = phi i64 [ %t3, %bb1 ], [ %t2, %bb4 ]
35 ret i64 %phi
Andrew Trickceafa2c2011-11-30 06:07:54 +000036}