1 ; RUN: opt -indvars -S %s -o - | FileCheck %s
3 ; When bailing out in rewriteLoopExitValues() you would be left with a PHI node
4 ; that was not deleted, and the IndVar pass would return an incorrect modified
5 ; status. This was caught by the expensive check introduced in D86589.
8 ; CHECK-NEXT: %idx = phi i64 [ %idx.next, %latch ], [ undef, %entry ]
9 ; CHECK-NEXT: %cond = icmp sgt i64 %n, %idx
10 ; CHECK-NEXT: br i1 %cond, label %end, label %inner.preheader
13 ; CHECK-NEXT: %idx.next = add nsw i64 %idx, -1
14 ; CHECK-NEXT: br label %header
16 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
17 target triple = "x86_64-unknown-linux-gnu"
19 @ptr = external global i64
21 define dso_local void @hoge() local_unnamed_addr {
22 entry: ; preds = %entry
23 %n = sdiv exact i64 undef, 40
26 header: ; preds = %latch, %entry
27 %idx = phi i64 [ %idx.next, %latch ], [ undef, %entry ]
28 %cond = icmp sgt i64 %n, %idx
29 br i1 %cond, label %end, label %inner
31 inner: ; preds = %inner, %header
32 %i = phi i64 [ %i.next, %inner ], [ 0, %header ]
33 %j = phi i64 [ %j.next, %inner ], [ %n, %header ]
34 %i.next = add nsw i64 %i, 1
35 %j.next = add nsw i64 %j, 1
36 store i64 undef, i64* @ptr
37 %cond1 = icmp slt i64 %j, %idx
38 br i1 %cond1, label %inner, label %inner_exit
40 inner_exit: ; preds = %inner
41 %indvar = phi i64 [ %i.next, %inner ]
42 %indvar_use = add i64 %indvar, 1
45 latch: ; preds = %inner_exit
46 %idx.next = add nsw i64 %idx, -1
49 end: ; preds = %header