1 ; RUN: opt < %s -S -passes='loop(indvars),loop-unroll' -verify-dom-info | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1"
4 target triple = "x86_64-unknown-linux-gnu"
6 ; Make sure that this test doesn't crash because of dangling pointer in SCEV.
7 declare void @llvm.experimental.guard(i1, ...)
9 define void @test(ptr %p, ptr %p2, ptr %dest) {
16 outer.loop: ; preds = %outer.latch, %entry
17 %local_2_ = phi i32 [ 10, %entry ], [ %tmp2, %outer.latch ]
18 %tmp1 = icmp eq i32 %local_2_, 0
21 outer.latch: ; preds = %inner.latch
22 %tmp2 = add i32 %local_2_, 1
25 inner.loop: ; preds = %inner.latch, %outer.loop
26 %local_4_20 = phi i32 [ 7, %outer.loop ], [ %tmp15, %inner.latch ]
27 %tmp6 = icmp eq i32 %local_4_20, 0
28 call void (i1, ...) @llvm.experimental.guard(i1 %tmp6) [ "deopt"() ]
29 br label %innermost.loop
31 store.block: ; preds = %innermost.loop
32 store i64 %tmp20, ptr %dest, align 8
33 br i1 %tmp1, label %exit, label %inner.latch
35 inner.latch: ; preds = %store.block
36 %tmp15 = add i32 %local_4_20, 4
37 %tmp16 = icmp sgt i32 %tmp15, 263
38 br i1 %tmp16, label %outer.latch, label %inner.loop
40 innermost.loop: ; preds = %innermost.loop, %inner.loop
41 %tmp17 = phi i64 [ 0, %inner.loop ], [ %tmp20, %innermost.loop ]
42 %local_6_51 = phi i32 [ 1, %inner.loop ], [ %tmp21, %innermost.loop ]
43 %ze = zext i32 %local_6_51 to i64
44 %tmp20 = add i64 %tmp17, %ze
45 %tmp21 = add nuw nsw i32 %local_6_51, 1
46 %tmp22 = icmp ugt i32 %local_6_51, 5
47 br i1 %tmp22, label %store.block, label %innermost.loop
49 exit: ; preds = %store.block